C++ Shortest and Most Readable Code, Brief Explanation, O(n) TC
IntuitionWhile iterating through the numbers, we will count the sum of the digits.
If we previously had that sum - which means we have it in our hashmap - we ch
# Intuition
While iterating through the numbers, we will count the sum of the digits.
If we previously had that sum - which means we have it in our hashmap - we check if the sum of these two numbers is larger than `res`.
Then, save in the hashmap the larger number of the two.

# Complexity
- Time complexity: O(n * log(m)) where n is the size of nums and m is the largest number in nums.

- Space complexity: O(n)

# Code
```cpp []
class Solution {
public:
    int sumDigits(int n) {
        int res = 0;
        while (n) {
            res += n % 10;
            n /= 10;
        }
        return res;
    }

    int maximumSum(vector<int>& nums) {
        unordered_map<int, int> sums;
        int res = -1;
        
        for (auto num : nums) {
            int digits = sumDigits(num);
            if (sums.count(digits)) res = max(res, num + sums[digits]);
            sums[digits] = max(sums[digits], num);
        }

        return res;
    }
};
```
## Like it? Please Upvote!
['C++']