Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Count the frequencies of each number. For example, if nums = [4,4,5,5,5], frequencies = [2,3].
Each customer wants all of their numbers to be the same. This means that each customer will be assigned to one number.
Use dynamic programming. Iterate through the numbers' frequencies, and choose some subset of customers to be assigned to this number.