Using basic math and hash map | C++
IntuitionThe total sum of array would be -> sum_element + n-2 special element(basically equal to sum_element) + outlier.
So if we subtract sum_element two times
# Intuition
The total sum of array would be -> sum_element + n-2 special element(basically equal to sum_element) + outlier.
So if we subtract sum_element two times from total sum we get the outlier.

# Approach
Store all values of the array into a hash map or another array.
Sum all the element of array and use that to get the outlier.
If there are multiple outlier we need to return the max.

**Edge Case:** The outlier and sum_element can be equal but not of same index so make sure of that.

# Complexity
- Time complexity:
O(N) as we are iterating array 2 times.

- Space complexity:
O(N) as we are storing all values in a hash map.

# Code
```cpp []
class Solution {
public:
    int getLargestOutlier(vector<int>& nums) {
        unordered_map<int,int> um;
        int n = nums.size(), allSum = 0; 
        for(int i=0; i<n; i++){
            allSum += nums[i];
            um[nums[i]] = i;
        }
        int res = INT_MIN;
        for(int i=0; i<n; i++){
            int rem = allSum - (2*nums[i]);
            if(um.find(rem) != um.end() && um[rem] != i){
                res = max(res, rem);
            }
        }
        return res;
    }
};
```
['C++']