Leetcode 1646 Solution

This article provides solution to leetcode question 1646 (kth-missing-positive-number)

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