⭐✅ EASY TO UNDERSTAND || C++ code || PRIORITY QUEUE
Make a map where each sum is mapped to a priority queue, which contains all the indexes where that sum is found:\n\nunordered_map<int, priority_queue<int>>mp;\n
Make a map where each sum is mapped to a priority queue, which contains all the indexes where that sum is found:\n\n`unordered_map<int, priority_queue<int>>mp;`\n\nFor each element of the nums array, compute the digit sum and add the mapping as follows:\n\n```\nfor(int i =0; i<n; i++)\n{\n\tmp[sol(nums[i])].push(nums[i]);\n}\n```\n\nFinally, go over each priority queue, if its size is greater than 1, take the top two numbers, and add them. Keep the sum only if its larger than the global max `mx` (which was initialized as INT_MIN) . \n\nIf our mx is still INT_MIN, then we could not find answer, return -1; else return mx.\n\n\n\n___\n___\n\nCODE:\n---\n\n```\nclass Solution {\npublic:\n    \n    int sol(int x)\n    {\n        int sum =0;\n        \n        while(x>0)\n        {\n            sum+=x%10;\n            x/=10;\n        }\n        \n        return sum;\n    }\n    \n    \n    int maximumSum(vector<int>& nums) {\n        \n        int n = nums.size();\n        unordered_map<int, priority_queue<int>>mp;\n        \n        for(int i =0; i<n; i++)\n        {\n\t\t\t// store the numbers in priority_queue mapped to a specific sum\n\t\t\t// NOTE: priority_queue has the actual numbers from nums array, and not the indexes\n            mp[sol(nums[i])].push(nums[i]);\n        }\n        \n        int mx = INT_MIN; // maintain a global max answer variable\n        for(auto&x : mp)\n        {\n\t\t\t// x will be the priority queue\n            if(x.second.size()>1)\n            {\n\t\t\t\t// take top two elements from pq, which are actually the numbers from nums array\n                int xx = x.second.top();\n                x.second.pop();\n                int y = x.second.top();\n                x.second.pop();\n\t\t\t\t\tmx = max(mx, xx+y); \n            }\n        }\n        \n        return (mx==INT_MIN) ? -1 : mx;\n    }\n};\n```
['Ordered Map', 'C', 'Heap (Priority Queue)', 'C++']