c++ || Count space || HashMap || 2284. Sender With Largest Word Count
\n\tclass Solution {\n\tpublic:\n\t\tstring largestWordCount(vector& messages, vector& senders) {\n\t\t\tmapm;\n\t\t\tfor(int i=0;imaxi)\n\t\t\t\t{\n\t\t\t\t\ta
\n\tclass Solution {\n\tpublic:\n\t\tstring largestWordCount(vector<string>& messages, vector<string>& senders) {\n\t\t\tmap<string,int>m;\n\t\t\tfor(int i=0;i<senders.size();i++)\n\t\t\t{\n\t\t\t\tint cnt=1;\n\t\t\t\tfor(int j=0;j<messages[i].size();j++)\n\t\t\t\t{\n\t\t\t\t\tif(messages[i][j]==\' \') cnt++;\n\t\t\t\t}\n\t\t\t\tm[senders[i]]+=cnt;\n\t\t\t}\n\t\t\tint maxi=INT_MIN;\n\t\t\tstring ans;\n\t\t\tfor(auto &i:m)\n\t\t\t{\n\t\t\t\tif(i.second>maxi)\n\t\t\t\t{\n\t\t\t\t\tans=i.first;\n\t\t\t\t}\n\t\t\t\telse if(i.second==maxi)\n\t\t\t\t{ \n\t\t\t\t\tif(i.first>ans) ans=i.first;\n\t\t\t\t}\n\t\t\t\tmaxi=max(maxi,i.second);\n\t\t\t}\n\t\t\treturn ans;\n\t\t}\n\t};
['C']