Tap here to switch tabs
Problem
Submissions

Problem: Partition Array Into K-Distinct Groups

Partition Array Into K-Distinct Groups asks whether all array elements can be partitioned into groups, each containing exactly k distinct values, and returns true or false.

Statement

You are given an integer array nums and an integer k.

Determine whether it is possible to partition all elements of nums into groups such that each group contains exactly k distinct elements and every element from nums belongs to exactly one group.

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

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤\leq nums.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Partition Array Into K-Distinct Groups

Partition Array Into K-Distinct Groups asks whether all array elements can be partitioned into groups, each containing exactly k distinct values, and returns true or false.

Statement

You are given an integer array nums and an integer k.

Determine whether it is possible to partition all elements of nums into groups such that each group contains exactly k distinct elements and every element from nums belongs to exactly one group.

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

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤\leq nums.length