Java Easy to Understand Solution with explanation
Code\n\nclass Solution {\n    public String largestWordCount(String[] messages, String[] senders) {\n        Map<String, Integer> ans = new TreeMap<>(); // Usin
# Code\n```\nclass Solution {\n    public String largestWordCount(String[] messages, String[] senders) {\n        Map<String, Integer> ans = new TreeMap<>(); // Using treemap for its Default Natural Sorting Order to tackle Lexicography.\n\t\tList<String> res = new ArrayList<>(); \n\t\tint n = messages.length;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (ans.containsKey(senders[i])) {\n\t\t\t\tint sum = ans.get(senders[i]) + messages[i].split(" ").length; // When the sender is already present add the subsequent message word lengths to current word length.\n\t\t\t\tans.put(senders[i], sum);\n\t\t\t} else\n\t\t\t\tans.put(senders[i], messages[i].split(" ").length);\n\t\t}\n\t\tint max = 0;\n\t\tfor (int i : ans.values()) {\n\t\t\tif (max < i)\n\t\t\t\tmax = i; // Find the longest message value. \n\t\t}\n\t\tfor (String s : ans.keySet()) {\n\t\t\tif (ans.get(s) == max)\n\t\t\t\tres.add(s); // Take all the Lexicographically ordered string in a list without disturbing the order.\n\t\t}\n\t\treturn res.get(res.size() - 1); // Always the last string would be the Lexicographically longest.\n    }\n}\n```\n\nPlease upvote if you like this solution. Thanks.
['Java']