算法1
(二分法) $O(log(n))$
blablabla
时间复杂度分析:blablabla
python 代码
class Solution(object):
def getMissingNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums or nums[0]!=0:
return 0
l,r=0,len(nums)-1
mid=0
while l<r:
mid=(l+r)//2
if nums[mid]==mid:
l=mid+1
else:
r=mid
if nums[l]==l:
return len(nums)
else:
return (nums[l-1]+1)