Interview Query

Find the missing number

Upvote
11
Downvote
Save
Mark Completed
Have you seen this question before?

You have an array of integers of length n spanning 0 to n with one missing. Write a function missing_number that returns the missing number in the array.

Note: Complexity of O(N)O(N) required.

Example:

Input:

nums = [0,1,2,4,5] 
missing_number(nums) -> 3
Next question: Estimating Birthdays
.....
Loading editor
Use Shift + Enter to run

Comments

Loading comments