Skip to content

Latest commit

 

History

History

kth-missing-positive-number

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Kth missing positive number

Problem link

Solutions

Solution.cpp

// https://leetcode.com/problems/kth-missing-positive-number

class Solution {
 public:
  int findKthPositive(vector<int>& arr, int k) {
    int n = arr.size();
    for (int i = 0; i < n; ++i)
      if (k + i < arr[i]) return k + i;
    return k + n;
  }
};

Tags