题解 | #扑克牌顺子#

扑克牌顺子

https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4

#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param numbers int整型一维数组 
# @return bool布尔型
#
class Solution:
    def IsContinuous(self , numbers: List[int]) -> bool:
        # write code here
        hash = set()
        for i in numbers:
            if i in hash:
                return False
            hash.add(i)
            if i == 0:
                hash.discard(0)
        min_value,max_value = min(hash), max(hash)
        if max_value - min_value >= 5:
            return False
        else:
            return True

全部评论

相关推荐

2025-11-07 15:41
暨南大学 C++
用微笑面对困难:我面试时候,就说了句”不愧是徐波的兵“他就破房了说是
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务