题解 | #扑克牌顺子#
扑克牌顺子
http://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4
# -*- coding:utf-8 -*-
class Solution:
def IsContinuous(self, numbers):
# write code here
min_, max_ = 14, 0
s = set()
zeros = 0
for n in numbers:
if n > 0:
if n in s:
return False
else:
s.add(n)
min_ = min(min_, n)
max_ = max(max_, n)
return max_ - min_ < 5
class Solution:
def IsContinuous(self, numbers):
# write code here
min_, max_ = 14, 0
s = set()
zeros = 0
for n in numbers:
if n > 0:
if n in s:
return False
else:
s.add(n)
min_ = min(min_, n)
max_ = max(max_, n)
return max_ - min_ < 5