20. Find the Missing Number
EasySearching
nums contains n distinct numbers from 0 to n with exactly one missing. Return the missing number.
Example 1
Input: nums = [3, 0, 1] Output: 2
Constraints
1 ≤ n ≤ 10⁴
EasySearching
nums contains n distinct numbers from 0 to n with exactly one missing. Return the missing number.
Input: nums = [3, 0, 1] Output: 2
1 ≤ n ≤ 10⁴Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor
Run checks these cases; the expected output comes from the reference solution. Submit judges all 4 hidden and sample tests.
Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.