using hash map and total sum
IntuitionThe largest outlier need to found. So sort the nums and try the largest number as the outlier. If it is the outlier, then the sum of remaining numbers
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The largest outlier need to found. So sort the nums and try the largest number as the outlier. If it is the outlier, then the sum of remaining numbers should be 2*(one of the remaining number)=> the sum of remaining numbers should be even and sum/2 can be found in the remaining numbers. 
So the total sum can be calculated and hashmap can be used to help searching. 

# Approach
<!-- Describe your approach to solving the problem. -->
use the hash map to store the num and its count
get the sum of all
try the current number to be outlier to see if the remaining sum is even and remaining sum /2 can be found in the remaining number.


# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
sort is O(nlogn). Since this problem is only need to know the larget outlier, sort isn't necessary and can use one variable to store the largest outlier and update it when the larger one is found.

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(n) ---use hash map to store the num count

# Code
```cpp []
class Solution {
public:
    int getLargestOutlier(vector<int>& nums) {
        unordered_map<int, int> num_count;
        int sum = 0;

        for(int i = 0; i < nums.size(); i++)
        {
            sum += nums[i];
            num_count[nums[i]]++;
        }

        sort(nums.begin(), nums.end());

        for(int i = nums.size() - 1; i >= 0; i--)
        {
            int sumL = sum - nums[i];
            if(sumL % 2)
            {
                continue;
            }

            num_count[nums[i]]--;

            if(num_count[sumL/2] > 0)
            {
                return nums[i];
            }

            num_count[nums[i]]++;
        }

        return -1;
        
    }
};
```
['C++']