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
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 4ms, memory 17.4MB, accepted 2025-12-30.
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