Intuition
The fundamental idea here is that we can calculate the number of missing integers on an index.
In an “ideal” list where no number is missing, arr[i] = i+1
. So, if there’s a mismatch in this logic, we can find number of missing numbers by missing = arr[i] - (i+1)
.
Code
Python3
Big O Analysis
-
Runtime
The runtime complexity here is since binary search and reducing the sample space by half every step.
-
Memory
The memory usage is since no extra data structure is being used.
— A