1)获取未缺失数字的列表,逐个对比(很慢!)
class Solution: def missingNumber(self, nums: List[int]) -> int: reallist = [i for i in range(len(nums)+1)] for i in reallist: if i not in nums: return i
2)求和问题
class Solution: def missingNumber(self, nums: List[int]) -> int: return sum([i for i in range(len(nums)+1)])-sum(nums)