c++ || priority queue + hashmap
\nclass Solution {\nprivate:\n    struct my_comparator {\n        bool operator() (const pair<int,string>&a, const pair<int,string>& b) {\n            if(a.firs
```\nclass Solution {\nprivate:\n    struct my_comparator {\n        bool operator() (const pair<int,string>&a, const pair<int,string>& b) {\n            if(a.first != b.first) {\n                return a.first > b.first;\n            }\n            else {\n                return a.second > b.second;\n            }\n        }\n    };\n    \n    int count_words(string str){\n        int count=0;\n        for(int i=0;i<str.size();i++){\n            if(str[i]==\' \'){ count++; }\n        }\n        return count+1;\n    }\npublic:\n    string largestWordCount(vector<string>& messages, vector<string>& senders) {\n        unordered_map<string, int> mp;\n        for(int i=0;i<messages.size();i++){\n            int temp = count_words(messages[i]);\n            mp[senders[i]] += temp;\n        }\n        \n        priority_queue<pair<int,string>, vector<pair<int,string>>,my_comparator> pq;\n        for(auto itrator: mp){\n            pq.push({itrator.second, itrator.first});\n            if(pq.size()>1){ \n                pq.pop(); \n            }\n        }\n        return pq.top().second;\n    }\n};\n```
['Heap (Priority Queue)']