본문 바로가기
python-algorithm

Leetcode 268. Missing Number

by 무적김두칠 2022. 3. 28.

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
반응형

댓글