Watch 10 video solutions for X of a Kind in a Deck of Cards, a easy level problem involving Array, Hash Table, Math. This walkthrough by Fireship has 1,309,101 views views. Want to try solving it yourself? Practice on FleetCode or read the detailed text solution.
You are given an integer array deck where deck[i] represents the number written on the ith card.
Partition the cards into one or more groups such that:
x cards where x > 1, andReturn true if such partition is possible, or 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.
Constraints:
1 <= deck.length <= 1040 <= deck[i] < 104