我的答案:(没满足说明吧ToT)
class Solution(object):
def missingNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
for i in range(len(nums)+1):
if i not in nums:
return i
正确答案:Accept(当然是别人想到的)https://blog.csdn.net/qq_34364995/article/details/80699747
(被折服。。)
class Solution(object):
def missingNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
nums.sort()
i=0
# 0,1,2
for value in nums:
if i-value != 0:
return i
else:
i += 1
return i
def main():
nums = [0]
myResult = Solution()
print(myResult.missingNumber(nums))
if __name__ == '__main__':
main()