Back to DSA

Missing Number

medium
Acceptance: 44%
Bit ManipulationMathArrays

An array holds n distinct integers drawn from the range [0, n]. Exactly one number in that range is absent. Find and return it.

Examples

Example 1:
Input:nums = [0,1,3]
Output:2
Example 2:
Input:nums = [5,3,0,1,4,2,7,6]
Output:8

Hints

00:00
1234567