Skip to content

Commit b6176fc

Browse files
authored
Create 1539. Kth Missing Positive Number
1 parent b1463d3 commit b6176fc

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
10000만까지 count하면서 존재하지 않으면 k를 감소.
6+
k가 0 이면 해당 숫자가 답
7+
8+
2. 시간복잡도 :
9+
O(10000)
10+
11+
3. 자료구조/알고리즘 :
12+
-
13+
14+
'''
15+
16+
class Solution:
17+
def findKthPositive(self, arr: List[int], k: int) -> int:
18+
num_set = set(arr)
19+
for i in range(1, 10000):
20+
if i not in num_set:
21+
k-=1
22+
if k == 0:
23+
return i

0 commit comments

Comments
 (0)