LeetCode solutions

1646. Kth Missing Positive Number

My accepted Python solution to LeetCode problem 1646, Kth Missing Positive Number, running in 4ms.

  • Difficulty: Easy
  • Python
  • Runtime 4ms
  • Memory 17.4MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 4ms, memory 17.4MB, accepted 2025-12-30.

python
class Solution:
    def findKthPositive(self, arr: List[int], k: int) -> int:
        arr_set = set(arr)
        missing_count = 0
        num = 0
        while missing_count < k:
            num += 1
            if num not in arr_set:
                missing_count += 1
        return num

Source