leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2284.cpp (610B)


0 class Solution { 1 public: 2 string largestWordCount(const vector<string> &messages, const vector<string> &senders) const { 3 unordered_map<string, int> um; 4 const int n = size(messages); 5 string res; 6 int maxi = 0; 7 for (int i = 0; i < n; i++) { 8 int cnt = 0; 9 for (const char c : messages[i]) 10 cnt += c == ' '; 11 cnt = um[senders[i]] += cnt + 1; 12 if (cnt != maxi ? cnt >= maxi : senders[i] > res) { 13 res = senders[i]; 14 maxi = cnt; 15 } 16 } 17 return res; 18 } 19 };