The Missing Element in Sorted Array problem gives you a sorted array of unique integers and asks for the k-th missing number starting from the first element of the array. Unlike standard "find missing number" problems, this one asks for the k-th missing value in an extended range. The Missing Element in Sorted Array coding problem tests binary search reasoning on sorted arrays with gaps.
PayPal, Meta, Amazon, and Google ask this because it tests binary search on a derived property — the number of missing integers before index i equals arr[i] - arr[0] - i. This non-trivial binary search setup differentiates candidates who can derive search conditions from those who only apply templates. The array and binary search interview pattern is the core here.
Binary search on missing count. At each index i, the count of missing numbers before arr[i] is arr[i] - arr[0] - i. Binary search for the rightmost index where missing count < k. If found at index lo, the k-th missing number is arr[lo] + (k - missing_count_at_lo).
Array: [4, 7, 9, 10]. k = 3.
Derived-property binary search problems require you to define a monotonic function over the array. Here, "count of missing numbers before index i" is monotonically non-decreasing, making binary search valid. Practice deriving such functions from array properties before applying binary search — this is the skill that unlocks a whole class of medium-to-hard binary search problems at companies like Meta and Google.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Cutting Ribbons | Medium | Solve | |
| H-Index II | Medium | Solve | |
| Minimum Time to Complete Trips | Medium | Solve | |
| Minimum Time to Repair Cars | Medium | Solve | |
| Maximum Candies Allocated to K Children | Medium | Solve |