Skip to main content

Checkpoint: the missing number

Challenge on lesson: Checkpoint: the missing number

CHALLENGE
Difficulty: beginner+25 XP

a holds n distinct values taken from 0..n with exactly one value missing. Implement missingNumber(int[] a): return the missing value, in one pass (O(n)) โ€” the expected sum trick.

Back to lesson: Checkpoint: the missing number