846. Hand of Straights (medium)
Hand of Straights is a Medium level problem. 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 Output: true Explanation: Alice's hand can be rearranged as [1,2,3],[2,3,4],[6,7,8] DISCUSSION: The first insight into this problem is related to groupSize and has two parts: groupSize of 1 should always return True since groups of 1 are always straights. groupSize must divide the hand length. In other words: len(hand)%groupSize == 0. If group size does not divide handLength then the hand can clearly not be rearranged into groupSize groups. The second insight into this problem is related to my solution strategy, which is that each group should start...