Count Spaces
\nclass Solution {\npublic:\n    string largestWordCount(vector<string>& messages, vector<string>& senders) {\n        map<string,int> sent;\n        int i=0;\n
```\nclass Solution {\npublic:\n    string largestWordCount(vector<string>& messages, vector<string>& senders) {\n        map<string,int> sent;\n        int i=0;\n        for(string msg:messages){\n            int state = 1;\n            int wc = 0;\n            for (char c:msg)\n            {\n                if (c == \' \' ) state = 1;\n                else if (state)\n                {\n                    state = 0;\n                    ++wc;\n                }\n            }\n            sent[senders[i]]+=wc;\n            i++;\n        }\n        int max=-1;\n        string ans="";\n        for(auto p:sent){\n            //word with max count\n            if(max< p.second){\n                max=p.second;\n                ans=p.first;\n            }\n            else if(max== p.second){\n\t\t\t//lexographically largest name\n                if(ans<p.first)\n                    ans=p.first;\n            }\n        }\n        return ans;\n    }\n};\n```
['String']