The K-th Missing Number
A strictly increasing array of positive integers is given. Print the K-th positive integer that does NOT appear in it.
Input: the first line has N and K; the second line has the N sorted values.
Output: the K-th missing positive integer.
Constraints:
- 1 ≤ N ≤ 105
- 1 ≤ K ≤ 105
- 1 ≤ ai ≤ 2×105, strictly increasing
Sample Tests
Input 1
4 2 2 3 4 7
Output 1
5
Input 2
2 4 1 2
Output 2
6
Discussion (opens after you solve — no spoilers before)
No comments yet.