-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path1090.py
16 lines (15 loc) · 784 Bytes
/
1090.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
__________________________________________________________________________________________________
class Solution:
def largestValsFromLabels(self, values: List[int], labels: List[int], num_wanted: int, use_limit: int) -> int:
count = collections.defaultdict(int)
combine = sorted(zip(values, labels), reverse=True)
result = length = 0
for v,l in combine:
if count[l] < use_limit:
count[l] += 1
result += v
length += 1
if length == num_wanted:break
return result
__________________________________________________________________________________________________
__________________________________________________________________________________________________