HTMLify

LeetCode - Hand of Straights - Python
Views: 2 | Author: abh
class Solution:
    def isNStraightHand(self, hand: List[int], groupSize: int) -> bool:
        if len(hand) % groupSize != 0:
            return False
        hand.sort()
        groups = []
        while hand:
            s = hand[0]
            for _ in range(groupSize):
                if s + _ not in hand:
                    return False
                hand.remove(s+_)
        return True

Comments