Leetcode 2284 Simple O(Nlog N)->TC ,O(N)- >SC solution
\'\'\'\nclass Solution {\npublic:\n    int count(string &s)\n    {   \n        //if string is empty ,there are no words\n        if(s.size()==0)\n            re
\'\'\'\nclass Solution {\npublic:\n    int count(string &s)\n    {   \n        //if string is empty ,there are no words\n        if(s.size()==0)\n            return 0;\n        int n=s.size();\n        //counter to count words\n        int c=0;\n        for(int i=0;i<n;i++)\n        {\n            if(s[i]==\' \')\n                c++;\n        }\n        //count of number of words is one more than count of spaces\n        return (c+1);\n    }\n    string largestWordCount(vector<string>& msg, vector<string>& s) \n    {\n        int n=msg.size();\n        //since we count frequency of words by sender\n        //we use long long to avoid overflow while counting\n        unordered_map<string,long long>m;\n        for(int i=0;i<n;i++)\n        {\n\t\t//we add 0LL to avoid overflow in integer by doing calculation in long long\n            m[s[i]]=m[s[i]]+0ll+count(msg[i]);\n        }\n        //we first find maximum frequency of words by any sender\n        long long maxi=0;\n        for(auto &i:m)\n        {\n            if((i.second+0ll)>maxi)\n                maxi=i.second;\n        }\n        //Then we find all senders with same maximum frequency and store them in vector\n        vector<string>ans;\n        for(auto &i:m)\n        {\n            if(i.second==maxi)\n            {\n                cout<<i.first<<" "<<i.second<<endl;\n                ans.push_back(i.first);\n            }\n        }\n        //we sort the answer vector to get lexicographically largest vector at end\n        sort(ans.begin(),ans.end());\n        return ans[ans.size()-1];\n    }\n};\n\'\'\'
['Sorting']