Sender with largest Word Count | Java Solution
\nclass Solution {\n    public String largestWordCount(String[] messages, String[] senders) {\n        HashMap<String, Integer> hm=new HashMap<>();//sender->wor
```\nclass Solution {\n    public String largestWordCount(String[] messages, String[] senders) {\n        HashMap<String, Integer> hm=new HashMap<>();//sender->word count\n        int n=messages.length;\n        for(int i=0;i<n;i++)\n        {\n            String sender=senders[i];\n            int wordCount=messages[i].split("\\\\s").length;\n            hm.put(sender,hm.getOrDefault(sender,0)+wordCount);\n        }\n        int largest=Integer.MIN_VALUE;\n        String ans="";\n        for(String sender:hm.keySet())\n        {\n            int value=hm.get(sender);\n            if(value > largest)\n            {\n                largest=value;\n                ans=sender;\n            }\n            else if(value == largest)\n            {\n                if(ans.compareTo(sender) < 0)\n                {\n                    ans=sender;\n                }\n            }\n        }\n        return ans;\n    }\n}\n```
['Java']