Simplest | C++ | O(n) | two pass
IntuitionSimple MathApproachcompute sum of all numbers.
Check all the numbers one by one,
If a number is outlier then (sum-outlier)/2 should be present in the a
# Intuition
Simple Math

# Approach
compute sum of all numbers.
Check all the numbers one by one,
If a number is outlier then (sum-outlier)/2 should be present in the array.

# Complexity
- Time complexity:
$$O(n)$$
Two passes on array

- Space complexity:
$$O(n)$$
To store map.

# Code
```cpp []
class Solution {
public:
    int getLargestOutlier(vector<int>& nums) 
    {
        int sum = 0;
        unordered_map<int, int> m;
        int ans = INT_MIN;
        for(int i=0;i<nums.size();i++)
        {
            sum = sum + nums[i];
            m[nums[i]]++;
        }
        
        for(int i=0;i<nums.size();i++){
            int outlier = nums[i];
            int remaining = sum - outlier;
            if(remaining%2==0 && m.find(remaining/2)!=m.end()){
                if(remaining/2 != outlier) ans = max(ans, outlier);
                if(remaining/2 == outlier && m[outlier]>1) ans = max(ans, outlier);
            }
        }
        return ans;
    }
};
```
['C++']