Easy Approach in Java | using HashMap Only
\n\nclass Solution {\n    public String largestWordCount(String[] messages, String[] senders) {\n        HashMap<String,Integer> hm=new HashMap<>();\n\t\t\n    
```\n\nclass Solution {\n    public String largestWordCount(String[] messages, String[] senders) {\n        HashMap<String,Integer> hm=new HashMap<>();\n\t\t\n        int max=0;\n        String name="";\n        for(int i=0;i<messages.length;i++){\n            String[] words=messages[i].split(" ");\n            \n            int freq=hm.getOrDefault(senders[i],0)+words.length;\n            hm.put(senders[i],freq);\n            \n            if(hm.get(senders[i])>max){\n                max=hm.get(senders[i]);\n                name=senders[i];\n            }\n            else if(hm.get(senders[i])==max && name.compareTo(senders[i])<0){\n                name=senders[i];\n            } \n        }\n        \n        return name;\n    }\n}\n```\n\n\n\n**Time Complexity - O(messages.length*messages[i].length)**\n**Space Compexity - O(senders.length);**\n\n**Connect with me ->** https://www.linkedin.com/in/himanshusharma2024/\n\n\n\n\n
['Java']