Skip to interview prep
Apexed

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⁴

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.

Find the Missing Number — coding interview practice — Apexed