# Leetcode 846 - Hand of Straights

Note:

• Sort hand first.
• Use map to record frequencies.
• For each head, get its count in map, and shift the array until hand[0] !== head.
• If count === 0, it means that we’ve used all of it before, jump to next iteration.
• Contruct consecutives based on the count, and if needed cards’ count is smaller than what we need, return false.
• Update map while constructing cards.

Question:

Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive cards.

Given an integer array hand where hand[i] is the value written on the ith card and an integer groupSize, return true if she can rearrange the cards, or false otherwise.

Example:

Code: