发布网友 发布时间:2022-04-25 21:05
共2个回答
热心网友 时间:2022-05-02 16:29
def isSeq(lis):
....lis.sort(key=lambda x:x[0])
....preNum = lis[0][0] -1
....for item in lis:
........if item[0] != preNum + 1:
............return False
........else:
............preNum = item[0]
....return True
热心网友 时间:2022-05-02 17:47
def continuous(seq):
if len(seq) < 2:
return False
seq = list(sorted(seq))
base = seq[0]
for i in seq[1:]:
if i - base != 1:
return False
base = i
return True
print(continuous([1,3,5,2,4]))
print(continuous([1,2,3,5,6]))