3
int largestValsFromLabels(vector<int> &values, vector<int> &labels, int numWanted, int useLimit) {4
// same label item should be less than uselimit5
priority_queue<pair<int, int>> q; // this will give us maximum element6
// because we need to maximise the sum7
for (int i = 0; i < values.size(); i++) {8
q.push({values[i], i});10
long long int ans = 0;11
unordered_map<int, int> m;12
// we cant use more numbers than useLimit13
// storing each use labels in map to count the use limit of that number15
while (i < numWanted) {16
int t = q.top().first; // number17
int ind = q.top().second; // labels index19
if (m[labels[ind]] < useLimit) // if less than count then include in our answer