Kth Missing Number
Given a list of sorted unique integers nums
and an integer k
, return the k
th (0-indexed) missing number from the first element of the list.
Constraints
n ≤ 100,000
wheren
is the length ofnums
.
https://binarysearch.com/problems/Kth-Missing-Number
Examples
Example 1
Input
- nums =
[5, 6, 8, 9]
- k =
3
Output
- answer =
12
Explanation
The first four missing numbers are [7, 10, 11, 12]
Example 2
Input
- nums =
[5, 6, 8, 9]
- k =
0
Output
- answer =
7
Explanation
7
is the first missing number.
Leave a comment