Java solution using HashMap
Approach
Calculate the total sum.
Store the values of each number in the array in a hashmap. A HashSet would have worked but we might have a scenario when the o
# Approach
<!-- Describe your approach to solving the problem. -->
- Calculate the total sum.
- Store the values of each number in the array in a hashmap. A HashSet would have worked but we might have a scenario when the outlier number chosen is the same as half of the (remainingSum / 2), and that would detect the presence of (remainingSum / 2) in the remaining numbers of the array. So use a hashmap to keep track of the number of occurrences of the numbers.
- Iterate through the array.
- currSum = totalSum - currentNum
- Subtract the current number and check if the currSum is even. Skip if it is odd.
- Check the map if the (currSum / 2) is present. If it is, also check that the current number is not the same as (currSum / 2) or if it is, perform a third check if there exists another occurrence of that particular number, which is different from the outlier chosen.
- Update max if conditions are met.
# 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
```java []
class Solution {
    public int getLargestOutlier(int[] nums) {
        int totalSum = 0;
        Map<Integer, Integer> mp = new HashMap<>();
        
        for(int i: nums) {
            totalSum += i;
            mp.put(i, mp.getOrDefault(i, 0)+1);
        }
        int max = Integer.MIN_VALUE;
        for(int i: nums) {
            int currSum = totalSum - i;
            if(currSum % 2 != 0) continue;
            if(mp.containsKey(currSum / 2)) {
                if((currSum / 2 != i) || (currSum / 2 == i && mp.get(currSum / 2) > 1)) {
                    max = Math.max(max, i);
                } 
            }
        }
        return max;
    }
}
```
['Java']