USING MAPS
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int maximumSum(vector<int>& nums) { 
        unordered_map<int,int>mp;//make mapping of key->sum of digits of elements of array
        int fans=-1;//to store final ans && if every key is different in map return -1
        for(int x:nums){//x is elements of vector
            int sum=0,temp=x;//temp variable to perform calculation to calculate sum of digits
            while(temp!=0)sum+=temp%10,temp/=10;//storing sum of digits of x without changing actual x
            if(mp.find(sum)!=mp.end())fans=max(fans,x+mp[sum]);//if found key find max of nums[i]+nums[j]
            mp[sum]=max(mp[sum],x);//to store max element in  key having same sum of digits 
        }
        return fans;
}
};
```
['C++']