Tap here to switch tabs
Problem
Submissions

Problem: X of a Kind in a Deck of Cards

med
30 min
Try to solve the X of a Kind in a Deck of Cards problem.

Statement

You are given an integer array deck where deck[i] represents the number written on the card at index i.

Determine whether you can choose an integer x where x ≥2\geq 2 such that the entire deck can be partitioned into 11 or more groups satisfying the following conditions:

  • Each group contains exactly x cards.

  • All cards in each group have the same number.

Return true if such a partition exists, or false otherwise.

Constraints:

  • 1≤1 \leq deck.length ≤104\leq 10^4

  • 0≤0 \leq deck[i] <104< 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: X of a Kind in a Deck of Cards

med
30 min
Try to solve the X of a Kind in a Deck of Cards problem.

Statement

You are given an integer array deck where deck[i] represents the number written on the card at index i.

Determine whether you can choose an integer x where x ≥2\geq 2 such that the entire deck can be partitioned into 11 or more groups satisfying the following conditions:

  • Each group contains exactly x cards.

  • All cards in each group have the same number.

Return true if such a partition exists, or false otherwise.

Constraints:

  • 1≤1 \leq deck.length ≤104\leq 10^4

  • 0≤0 \leq deck[i] <104< 10^4