easyArrayCountingHash TableMathNumber Theory 0 views

X of a Kind in a Deck of Cards

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

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:

Return true if such partition is possible, or false otherwise.

X of a Kind in a Deck of Cards diagram

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 <= 10^4
  • 0 <= deck[i] < 10^4

Hints

No hints yet.

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.