TreeMap | Java Solution
\nclass Solution {\n    public String largestWordCount(String[] messages, String[] senders) {\n        // retains the String order. Hence, we can find the lexic
```\nclass Solution {\n    public String largestWordCount(String[] messages, String[] senders) {\n        // retains the String order. Hence, we can find the lexicographically largest name if more than one sender with the largest word count \n        TreeMap<String, Integer> map= new TreeMap<>();\n        \n        for(int i=0;i<messages.length;i++)\n        {\n            int c= countWords(messages[i]);\n            map.put(senders[i],map.getOrDefault(senders[i],0)+c);\n        }\n        int max=0;\n        String ans="";\n        for(String k: map.keySet())\n        {\n\t\t\t//>= since we need to find the lexicographically largest\n            if(map.get(k)>=max)\n            {\n                max=map.get(k);\n                ans=k;\n            }\n        }\n        return ans;\n    }\n    public int countWords(String str)\n    {\n\n        if (str == null || str.isEmpty())\n            return 0;\n        String[] words = str.split("\\\\s+");\n        return words.length;\n    }\n}\n```
['Tree', 'Java']