Simple C++ solution || Only map || O(n)
Intuition\nWe only need the 2 maximum elements for a particular sum\n\n# Approach\n Create a map to store the curr maximum number for that sum\n\n# Complexity\n
# Intuition\nWe only need the 2 maximum elements for a particular sum\n\n# Approach\n Create a map to store the curr maximum number for that sum\n\n# Complexity\n- Time complexity:\n  O(N)\n- Space complexity:\nO(N)\n\n# Code\n```\nclass Solution {\npublic:\n    int num_sum(int x){\n        int ans=0;\n        while(x){\n            ans+=x%10;\n            x/=10;\n        }\n        return ans;\n    }\n    int maximumSum(vector<int>& nums) {\n        unordered_map<int,int> mp;// sum, number\n        int ans=-1;\n        for(int i=0;i<nums.size();i++){\n            int sum=num_sum(nums[i]);\n            if(mp.find(sum)!=mp.end()){\n                ans=max(ans,nums[i]+mp[sum]);\n                mp[sum]=max(mp[sum],nums[i]);\n            }else mp[sum]=nums[i];\n        }\n        return ans;\n    }\n};\n```
['Hash Table', 'C++']