# 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:`

1 | Input: hand = [1,2,3,6,2,3,4,7,8], groupSize = 3 |

`Code:`

1 | /** |