✅✅Beats 100%🔥C++🔥Python|| 🚀🚀Super Simple and Efficient Solution🚀🚀||🔥Python🔥C++✅✅
Complexity
Time complexity: O(n)

Space complexity: O(n)
Code⬆️👇⬆️UPVOTE it⬆️👇⬆️
# Complexity
- Time complexity: $$O(n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

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

# Code
```cpp []
class Solution {
 public:
  int maximumSum(vector<int>& nums) {
    constexpr int kMax = 9 * 9;
    int ans = -1;
    vector<vector<int>> count(kMax + 1);
    for (const int num : nums)
      count[getDigitSum(num)].push_back(num);
    for (vector<int>& groupNums : count) {
      if (groupNums.size() < 2)
        continue;
      ranges::sort(groupNums, greater<>());
      ans = max(ans, groupNums[0] + groupNums[1]);
    }
    return ans;
  }

 private:
  int getDigitSum(int num) {
    int digitSum = 0;
    while (num > 0) {
      digitSum += num % 10;
      num /= 10;
    }
    return digitSum;
  }
};
```
```python []
class Solution:
  def maximumSum(self, nums: list[int]) -> int:
    kMax = 9 * 9  
    ans = -1
    count = [[] for _ in range(kMax + 1)]
    for num in nums:
      count[self._getDigitSum(num)].append(num)
    for groupNums in count:
      if len(groupNums) < 2:
        continue
      groupNums.sort(reverse=True)
      ans = max(ans, groupNums[0] + groupNums[1])
    return ans
  def _getDigitSum(self, num: int) -> int:
    return sum(int(digit) for digit in str(num))
```

⬆️👇⬆️UPVOTE it⬆️👇⬆️
['Array', 'Hash Table', 'Sorting', 'Heap (Priority Queue)', 'C++', 'Python3']