Description
Given an array arr of positive integers sorted in a strictly increasing order, and an integer k. Return the kth positive integer that is missing from this array.
Examples
Input:
arr = [2,3,4,7,11], k = 5Output:
9Explanation:
Missing: 1,5,6,8,9,10... 5th is 9.
Input:
arr = [1,3,5,7,9], k = 3Output:
6Explanation:
The array starts with 1, so the missing values are: 2, 4, 6, 8, 10, 11... The 3rd missing positive integer is 6.
Input:
arr = [10,20,30], k = 7Output:
7Explanation:
Missing positive integers are: 1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,21... The 7th missing positive integer is 7.
Constraints
- •
1 ≤ arr.length ≤ 1000 - •
1 ≤ arr[i] ≤ 1000