Java map solution easier to understand than frequency count
IntuitionSeeing everyone using a frequency count map, while we could actually use a value to index map, which i think is easier to understand.ApproachAssume tar

# Intuition
Seeing everyone using a frequency count map, while we could actually use a value to index map, which i think is easier to understand.

# Approach
Assume target is the number that is the sum of the n - 2 nums, so we have target, outlier and other n - 2 numbers summing up to target in the array. So total sum - outlier == 2 * target. For each outlier, we find if target is in the map and its index should not be the outlier's index. We use a valueToIndex map to find the index.

# Complexity
- Time complexity:
O(n)

- Space complexity:
<O(n)

# Code
```java []
class Solution {

    public int getLargestOutlier(int[] nums) {
        int n = nums.length;
        Map<Integer, Integer> valueToIndex = new HashMap<>();
        int totalSum = 0;
        for (int i = 0; i < nums.length; i++) {
            valueToIndex.put(nums[i], i);
            totalSum += nums[i];
        }
        int globalMax = Integer.MIN_VALUE;
        for (int i = 0; i < nums.length; i++) {
            if ((totalSum - nums[i]) % 2 != 0) {
                continue;
            }
            if (valueToIndex.containsKey((totalSum - nums[i]) / 2) && 
            valueToIndex.get((totalSum - nums[i]) / 2) != i) {
                globalMax = Math.max(globalMax, nums[i]);
            }
        }
        return globalMax;
    }
}


```
['Java']