def IsContinuous(seq, num = 5): zeros = 0; d = 0 seq = sorted(seq) for i in range(num - 1): if seq[i] == 0: zeros += 1 continue if seq[i] == seq[i + 1]: return False d += seq[i + 1] - seq[i] - 1 return zeros >= d
【剑指offer】:Q44:扑克牌的顺子,布布扣,bubuko.com
原文地址:http://blog.csdn.net/shiquxinkong/article/details/36645445