very easy to understand using HashMap
\nclass Solution {\n\tpublic int maximumSum(int[] arr) {\n\t\tHashMap<Integer, ArrayList<Integer>> map = new HashMap<>();\n\t\tfor (int i = 0; i < arr.length; i
```\nclass Solution {\n\tpublic int maximumSum(int[] arr) {\n\t\tHashMap<Integer, ArrayList<Integer>> map = new HashMap<>();\n\t\tfor (int i = 0; i < arr.length; i++) {\n\t\t\tint temp = getSum(arr[i]);\n\t\t\tmap.putIfAbsent(temp, new ArrayList<Integer>());\n\t\t\tmap.get(temp).add(arr[i]);\n\t\t}\n\t\tint ans = -1;\n\t\tfor (Map.Entry<Integer, ArrayList<Integer>> i : map.entrySet()) {\n\t\t\tArrayList<Integer> list = i.getValue();\n\t\t\tCollections.sort(list);\n\t\t\tif (list.size() >= 2) {\n\t\t\t\tans = Math.max(ans, list.get(list.size() - 1)+ list.get(list.size() - 2));\n\t\t\t}\n\t\t}\n\t\treturn ans;\n\n\t}\n\n\tpublic int getSum(int n) {\n\t\tint sum = 0;\n\t\twhile (n != 0) {\n\t\t\tsum = sum + n % 10;\n\t\t\tn = n / 10;\n\t\t}\n\t\treturn sum;\n\t}\n}\n```
['Java']