Dashboard Temp Share Shortlinks Frames API

HTMLify

LeetCode - Hand of Straights - Python
Views: 297 | Author: abh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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