1
2
3
4
5
6
|
class Solution:
def missingNumber(self, nums: List[int]) -> int:
nums_sum=sum(nums)
n=len(nums)
compared=n*(n+1)//2
return compared-nums_sum
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 1185. Day of the Week (0) | 2022.03.28 |
---|---|
leetcode 448. Find All Numbers Disappeared in an Array (0) | 2022.03.28 |
leetcode 2129. Capitalize the Title (0) | 2022.03.25 |
leetcode 217. Contains Duplicate (0) | 2022.03.24 |
leetcode 389. Find the Difference (0) | 2022.03.24 |
댓글