Easy · Math

Find missing number

Given an array nums of n distinct integers taken from the range 0..n, return the one number in that range that does not appear in nums.

Examples

Example 1

[3,0,1] → 2

Output: missing = 2

Example 2

[0,1,3,4] → 2

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 Math problems