AcWing 81. 扑克牌的顺子
原题链接
简单
作者:
XianZS.com
,
2024-09-10 21:26:33
,
所有人可见
,
阅读 1
class Solution(object):
def isContinuous(self, numbers):
"""
:type numbers: List[int]
:rtype: bool
"""
n=len(numbers)
if n<5:
return False
numbers=sorted(numbers,reverse=True)
c=numbers.count(0)
for _ in range(c):
numbers.pop()
n-=c
minnum=min(numbers)
maxnum=max(numbers)
# print(numbers,n)
dnums=[0 for _ in range(maxnum-minnum+1)]
# print(dnums)
for x in range(n-1,-1,-1):
dnums[abs(minnum-numbers[x])]=1
# print(dnums)
newc=dnums.count(0)
if newc==0:
return True
if dnums.count(0)!=c:
return False
return True