Skip to content

Commit 813c98d

Browse files
committed
Runtime: 428 ms (Top 34.44%) | Memory: 77.6 MB (Top 40.48%)
1 parent f50c612 commit 813c98d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1+
// Runtime: 428 ms (Top 34.44%) | Memory: 77.6 MB (Top 40.48%)
12
class Solution {
23
public:
34
string largestWordCount(vector<string>& messages, vector<string>& senders) {
4-
5+
56
int n(size(messages));
67
map<string, int> m;
78
for (auto i=0; i<n; i++) {
8-
9+
910
stringstream ss(messages[i]);
1011
string word;
1112
int count(0);
12-
while (ss >> word) count++;
13+
while (ss >> word) count++;
1314
m[senders[i]] += count;
1415
}
15-
16+
1617
int count(0);
1718
string res;
1819
for (auto& p : m) {
1920
if (p.second >= count) {
2021
count = p.second;
21-
if (!res.empty() or res < p.first) res = p.first;
22+
if (!res.empty() or res < p.first) res = p.first;
2223
}
2324
}
2425
return res;
2526
}
26-
};
27+
};

0 commit comments

Comments
 (0)