[Java] Code with comments || HashMap + PriorityQueue
\nclass Solution {\n    \n    class Pair {\n        String name;\n        int cnt;\n        \n        public Pair(String n, int c) {\n            this.name = n;
```\nclass Solution {\n    \n    class Pair {\n        String name;\n        int cnt;\n        \n        public Pair(String n, int c) {\n            this.name = n;\n            this.cnt = c;\n        }\n    }\n    \n    class Compare implements Comparator<Pair> {\n        public int compare(Pair a, Pair b) {\n            if (a.cnt == b.cnt) {\n                return b.name.compareTo(a.name);\n            }\n            \n            return b.cnt - a.cnt;\n        }\n    }\n    \n    public String largestWordCount(String[] messages, String[] senders) {\n        PriorityQueue <Pair> pq = new PriorityQueue<>(new Compare());\n        /* Pair ==> key   -> name\n                ==> Value -> cnt\n           \n           new Compare() ==> it sort the queue on the cnt in descending order.\n                         ==> if cnt are same than sort on the name\n        */\n        \n        HashMap <String, Integer> hash = new HashMap<>();\n        \n        for (int i = 0; i < messages.length; i++) {\n            String []str = messages[i].split(" ");  // total words in a message\n            int len = str.length + hash.getOrDefault(senders[i], 0);\n            hash.put(senders[i], len);\n        }\n        \n        for (Map.Entry <String, Integer> map: hash.entrySet()) {\n            pq.add(new Pair(map.getKey(), map.getValue()));\n        }\n        \n        return pq.poll().name;\n    }\n    \n}\n```
['Heap (Priority Queue)', 'Java']