Skip to content

Commit a1c1aba

Browse files
authored
Create 1539. Kth Missing Positive Number.py
1 parent 74a6f43 commit a1c1aba

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def solution(arr,k):
2+
for i in range(len(arr)):
3+
missing = arr[i] - i - 1
4+
print(missing)
5+
6+
if missing >= k:
7+
return arr[i] - (missing - k + 1)
8+
return arr[-1] + (k - missing)
9+
10+
arr = [5,6,7,8,9]
11+
k = 9
12+
13+
print(solution(arr,k))
14+
15+

0 commit comments

Comments
 (0)