Find the Missing Number
We are given an array containing ‘n’ distinct numbers taken from the range 0 to ‘n’. Since the array has only ‘n’ numbers out of the total ‘n+1’ numbers, find the missing number.
Example 1:
Input: [4, 0, 3, 1]
Output: 2
TC – O(n)
SC – O(1)
Input: [4, 0, 3, 1]
Output: 2
Pseudo code:
Takeaway: Take the while loop where index less than array length