846. Hand of Straights

class Solution(object):
    def isNStraightHand(self, hand, groupSize):
        if len(hand) % groupSize:
            return False

        count = {}

        for n in hand:
            count[n] = count.get(n, 0) + 1

        minH = list(count.keys())
        heapq.heapify(minH)

        while minH:
            first = minH[0]

            for i in range(first, first + groupSize):
                if i not in count:
                    return False
                count[i] -= 1
                if count[i] == 0:
                    if i != minH[0]:
                        return False
                    heapq.heappop(minH)

        return True