Count Spaces | Maps | C++ | Easy to understand
We simply count the words for each sender and store the sender and their count of words in a map.\n\nFinally we iterate over the map and find sender with max wo
We simply count the words for each sender and store the sender and their count of words in a map.\n\nFinally we iterate over the map and find sender with max word count.\n\n```\nclass Solution {\n\t// Count number of words in a message by counting spaces\n    int f(string s) {\n        int words = 0;\n        for(auto &el: s) {\n            if(el == \' \') words++;\n        }\n        return words + 1;\n    }\npublic:\n    string largestWordCount(vector<string>& m, vector<string>& s) {\n        int n = m.size();\n        map<string, int> mp;\n        for(int i=0; i<n; i++) {\n            int words = f(m[i]);\n            mp[s[i]] += words;\n        }\n        \n        int maxLen = INT_MIN;\n        string ans;\n        for(auto &el: mp) {\n            if(el.second > maxLen) {\n                maxLen = el.second;\n                ans = el.first;\n            }\n            if(el.second == maxLen && el.first > ans) {\n                ans = el.first;\n            } \n        }\n        return ans;\n    }\n};\n```
['C']