LeetCode 914, Easy. Topics: Array, Hash Table, Math, Counting, Number Theory, Euclidean Algorithm, Greatest Common Divisor. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 24 parametrized pytest cases, and a playground notebook:
Problem
You are given an integer array deck where deck[i] represents the number written on the i^th card.
Partition the cards into one or more groups such that:
- Each group has exactly
x cards where x > 1, and
- All the cards in one group have the same integer written on them.
Return true if such partition is possible, or false otherwise.
Examples
Explanation: Possible partition [1,1],[2,2],[3,3],[4,4].
Explanation: No possible partition.
Constraints
- 1 <= deck.length <= 10^4
- 0 <= deck[i] < 10^4
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Last modified on September 7, 2026