#914
X of a Kind in a Deck of Cards
pupil · 540 · lc easy +28 · verified · 30.2% accepted · 1,901 likes · top 7%
Description
Given an integer array deck of card values, decide whether the deck can be divided into groups such that every group has the same size (at least 2) and every card in a group bears the same value. Return true if possible, false otherwise.
Example 1:
Input: deck = [1,2,3,4,4,3,2,1]
Output: true
Explanation: Possible partition [1,1],[2,2],[3,3],[4,4].
Example 2:
Input: deck = [1,1,1,2,2,2,3,3]
Output: false
Explanation: No possible partition.
Code
1
2
3