✔️ Easiest Solution Ever & Beginner Friendly ✔️ | 🌟 O(N * LogN) 🌟 | 🔥 HashMap + DigitSum 🔥 
IntuitionWe need to find the maximum sum of two numbers that share the same sum of digits. The naive approach using nested loops is O(N2), which is inefficient
# Intuition
We need to find the **maximum sum of two numbers** that share the same sum of `digits`. The naive approach using **nested loops** is $$O(N²)$$, which is **inefficient for large inputs**. Instead, we use a `HashMap` | `unordered_map` to store the maximum number for each `digitSum`.


# Approach
`Step 1` **Initialize a HashMap (Java) / unordered_map (C++)**
- This will store the **maximum number** corresponding to each `digitSum`.

`Step 2` **Iterate through the array**
- Compute the **sum of digits** of the `current` number.
- If the `digitSum` already exists in the `map`:
    - Update `maxSumPair` using the **sum of the current number** and the **existing number** in the `map`.
    - Update the `map` to keep the **maximum** of the **two numbers**.
- Otherwise, store the `current` number in the `map`.

`Step 3` **Return the maximum sum found or -1** 

# Complexity
- Time complexity : $$O(n * logn)$$
- Space complexity : $$O(n)$$

# Code
```Java []
class Solution 
{
    public int maximumSum(int[] nums) 
    {
        // Step 1: Store max number for each digit sum
        HashMap<Integer, Integer> map = new HashMap<>(); 
        
        // Step 2: Initialize result
        int maxSumPair = -1; 

        // Step 3: Iterate through each number
        for (int num : nums)
        { 
            int digitSum = getDigitSum(num);

            // Step 4: If sum exists, check max sum
            if (map.containsKey(digitSum))
            { 
                maxSumPair = Math.max(maxSumPair, num + map.get(digitSum)); 
                map.put(digitSum, Math.max(map.get(digitSum), num));
            }
            else
            {
                // Step 5: Store new sum of digits in map
                map.put(digitSum, num);
            }
        }
        
        // Step 6: Return max sum found
        return maxSumPair; 

    }

    // Step 10: Helper function to compute digit sum
    private int getDigitSum(int num)
    { 
        int sum = 0;
        while (num > 0)
        {
            sum += (num % 10);
            num /= 10;
        }
        
        return sum;
    }
}
```
``` C++ []
class Solution
{
public:
    int maximumSum(vector<int>& nums)
    {
        // Step 1: Store max number for each digit sum
        unordered_map<int, int> map;
         
        // Step 2: Initialize result
        int maxSumPair = -1;

        // Step 3: Iterate through each number
        for (int num : nums)
        { 
            int digitSum = getDigitSum(num); 

            // Step 4: If sum exists, check max sum
            if (map.find(digitSum) != map.end())
            { 
                maxSumPair = max(maxSumPair, num + map[digitSum]); 
                map[digitSum] = max(map[digitSum], num); 
            }
            else
            {
                // Step 5: Store new sum of digits in map
                map[digitSum] = num; 
            }
        }

        // Step 6: Return max sum found
        return maxSumPair; 
    }

private:

    // Step 7: Helper function to compute digit sum
    int getDigitSum(int num)
    { 
        int sum = 0;
        while (num > 0)
        {
            sum += (num % 10);
            num /= 10;
        }

        return sum;
    }
};
```
['Array', 'Hash Table', 'Two Pointers', 'Greedy', 'Topological Sort', 'Brainteaser', 'Ordered Map', 'Sorting', 'C++', 'Java']