Easy · Binary Search

Missing Number (Reference problems)

Given an array nums of n distinct numbers taken from the range 0 to n, return the only number in that range that is missing from the array.

Examples

Example 1

[3,0,1]

Output: missing 2

Example 2

[0,1]

Output: missing 2

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Binary Search problems