【劍指offer】撲克牌順子
阿新 • • 發佈:2018-12-16
執行時間:24ms
佔用記憶體:5732k
排序後判斷的
# -*- coding:utf-8 -*- class Solution: def IsContinuous(self, numbers): # write code here if not numbers: return None numbers.sort() print(numbers) cntw = 0 n = len(numbers) for i in range(n): if numbers[i] == 0: cntw += 1 elif i>0 and numbers[i-1]!=0: if numbers[i]==numbers[i-1]: return False elif numbers[i]-numbers[i-1]>1: if cntw < numbers[i]-numbers[i-1]-1: return False break else: cntw -= numbers[i]-numbers[i-1]-1 return True
大佬們回答出bitmap排序思想,沒咋看懂