Smooth af || explanation in comments with Clean Code || C++
\nclass Solution {\nprivate:\n    \n    int solve(string &s) //this function is to count the number of spaces\n    {\n        s += \' \';\n        int cnt =0;\n
```\nclass Solution {\nprivate:\n    \n    int solve(string &s) //this function is to count the number of spaces\n    {\n        s += \' \';\n        int cnt =0;\n        for(int i=0; i<s.length(); i++)\n        {\n            if(s[i]==\' \') cnt++;\n        }\n        return cnt;\n    }\n    \npublic:\n    \n    string largestWordCount(vector<string>& messages, vector<string>& senders) {\n        map<string,int> mp;\n        for(int i=0; i<messages.size(); i++)\n        {\n            int words = solve(messages[i]);\n            mp[senders[i]]+= words;\n        }\n        \n        string ans;\n        int max_words = -1;\n        for(auto &it : mp)\n        {\n            if(it.second == max_words)\n            {\n                char temp = it.first[0];\n                ans = (ans[0]>temp) ? ans : it.first;  //this will return the lexicographically greater string!!\n            }\n            \n            else if(it.second > max_words)\n            {\n                ans = it.first;\n                max_words = it.second;\n            }\n        }\n        return ans;\n    }\n};\n```\n
['String']