文章目录
原题题目
代码实现(首刷自解)
class Solution {
public:
int findKthPositive(vector<int>& arr, int k) {
int pos = 0,pre = 0;
while(pos < arr.size())
{
int disappear_num = arr[pos] - pos - 1;
if(disappear_num >= k)
return pos + k;
pre = arr[pos++];
}
return arr.size()+k;
}
};