[InterviewBit] Highest Score

Highest Score

  • Time :
  • Space :
1
2
3
4
5
6
7
8
9
10
11
12
13
int Solution::highestScore(vector<vector<string>> &A) {
unordered_map<string, int> sum, cnt;
for(auto a : A) {
int score = stoi(a[1]);
sum[a[0]] += score;
cnt[a[0]] += 1;
}
int res = 0;
for(auto& [k,v] : sum) {
res = max(res, v / cnt[k]);
}
return res;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2022/11/18/PS/interviewbit/highest-score/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.