1090. Largest Values From Labels
There is a set of n items. You are given two integer arrays values and labels where the value and the label of the ith element are values[i] and labels[i] respectively. You are also given two integers numWanted and useLimit.
Choose a subset s of the n elements such that:
- The size of the subset s is less than or equal to numWanted.
- There are at most useLimit items with the same label in s.
The score of a subset is the sum of the values in the subset.
Return the maximum score of a subset s.
1 | class Solution { |