Simple Java Solution in O(n).
\nclass Solution {\n    public String largestWordCount(String[] messages, String[] senders) {\n        ArrayList<String> key=new ArrayList();\n        HashMap<S
```\nclass Solution {\n    public String largestWordCount(String[] messages, String[] senders) {\n        ArrayList<String> key=new ArrayList();\n        HashMap<String, Integer> mp=new HashMap();\n        int max = Integer.MIN_VALUE;\n        for(int i=0;i<messages.length;i++){\n            int temp = messages[i].split(" ").length;\n            if(mp.containsKey(senders[i])){\n                mp.put(senders[i], mp.get(senders[i])+temp);\n            }\n            else{\n                mp.put(senders[i],temp);\n                key.add(senders[i]);\n            }\n            max = Math.max(max, mp.get(senders[i]));\n        }\n        Collections.sort(key);\n        for(int i=key.size()-1;i>=0;i--){\n            if(mp.get(key.get(i))==max)return key.get(i);\n        }\n        return "";\n    }\n}\n```
[]