Leetcode 1646 Solution
This article provides solution to leetcode question 1646 (kth-missing-positive-number)
Access this page by simply typing in "lcs 1646" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/kth-missing-positive-number
Solution
class Solution:
def findKthPositive(self, arr: List[int], k: int) -> int:
cur = 0
for ele in arr:
dist = ele - cur - 1
if k <= dist:
break
else:
k -= dist
cur = ele
return cur + k