Dashboard
LC #268
Missing Number
Pattern · ?AmazonGoogleMicrosoftApple
Problem
Given an array nums of n distinct numbers in the range [0, n], find and return the one number that is missing.
Constraints
- n == nums.length
- 1 ≤ n ≤ 10⁴
- 0 ≤ nums[i] ≤ n
- All numbers are unique
- O(1) extra space preferred
Example
- Input
- nums = [3, 0, 1]
- Output
- 2
- Why
- n = 3, range [0,3]. All present except 2
Spot the pattern
Which pattern cracks it?
Hints
One at a time