思路:去0,通过上下界来判断缺失间隔和摸到牌的数量之间的间隔。
def isc(nums):
l = numsnums = [num for num in nums if num!=0]
t = {nums[0]}
min_ = max_ = nums[0]
for i in nums[1:]:
if i in t:
return False
else:
max_ = max(max_,i)
min_ = min(min_,i)
if max_-min_>len(l)-1:
return False
t.add(i)
return True