Skip to content

Commit ffc5190

Browse files
Merge pull request #1828 from CodingTestStudy2/변지협
[변지협] Day15
2 parents 822b978 + 7d0a48c commit ffc5190

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'''
2+
1. 아이디어 :
3+
arr 뒤집고 pop()할 때는 ans에 안넣음.
4+
5+
2. 시간복잡도 :
6+
7+
3. 자료구조/알고리즘 :
8+
'''
9+
class Solution:
10+
def findKthPositive(self, arr: List[int], k: int) -> int:
11+
i = 1
12+
lmt = 0
13+
arr = arr[::-1]
14+
while True:
15+
if len(arr) == 0:
16+
lmt += 1
17+
elif arr[-1] == i:
18+
arr.pop()
19+
else:
20+
lmt += 1
21+
22+
if lmt == k:
23+
break
24+
i += 1
25+
26+
return i

0 commit comments

Comments
 (0)