class Solution:
def IsContinuous(self, numbers:List):
if not numbers:return []
numbers.sort()
cnt0=numbers.count(0)
cnt_not=0
for i in range(cnt0,4):
gap=numbers[i + 1] - numbers[i] - 1
if gap==-1:return False #很重要,因为会有重复数字
cnt_not+=gap
if cnt0>=cnt_not:return True
else:return False
网友评论