Search results
Missing Number - Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
Find All Numbers Disappeared in an Array - Given an array nums of n integers where nums [i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums.
Problem. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1 : Input: nums = [3,0,1] Output: 2. Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
Aug 24, 2016 · By calculating the sum of $[0,..n]$, subtracting the sum of all numbers in the array, we can obtain the missing number. The time complexity is $O(n)$, where $n$ is the length of the array. The space complexity is $O(1)$.
Problem: Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1]
Missing Number. Easy. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity? Example 1: Input: nums = [3,0,1] Output: 2.