Find Missing Number

Given an array containing n distinct numbers from range 0 to n, find the missing number.

Input Format

nums = array of distinct integers from 0 to n

Output Format

The missing integer from range 0 to n

Constraints

  • 0 <= nums[i] <= n <= 10^4; array length = n

Examples

Example 1:

Input:

nums = [3,0,1]

Output:

2

Explanation:

Numbers from 0 to 3 are present except 2.

Loading...
Find Missing Number - Arrays DSA Problem