Tap here to switch tabs
Problem
Submissions

Problem: Partition Array Into K-Distinct Groups

med
30 min
Try to solve the Partition Array Into K-Distinct Groups problem.

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

med
30 min
Try to solve the Partition Array Into K-Distinct Groups problem.

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