Skip to content

Commit 726459c

Browse files
committed
missing-number solution
1 parent 666ad79 commit 726459c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

missing-number/sungjinwi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
풀이 : 비지 않을경우 합 nSum을 구하고 list를 돌면서 빼고 남은 것이 답
3+
4+
5+
TC : O(N)
6+
sum구할 떄 O(N) + for문 O(N) = O(2N)\
7+
8+
SC : O(1)
9+
"""
10+
11+
class Solution:
12+
def missingNumber(self, nums: List[int]) -> int:
13+
nSum = sum(range(0,len(nums) + 1))
14+
for num in nums :
15+
nSum -=num
16+
return nSum

0 commit comments

Comments
 (0)