Easy · Binary Search

Missing Number

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

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Binary Search problems