Java HashMap O(N) Time and Space
\nclass Solution {\n    public int getLargestOutlier(int[] nums) {\n        \n        int n = nums.length;\n        \n        Map<Integer, Integer> map = new Ha
```\nclass Solution {\n    public int getLargestOutlier(int[] nums) {\n        \n        int n = nums.length;\n        \n        Map<Integer, Integer> map = new HashMap<>();\n        \n        int sum = 0;\n        \n        for(int i = 0; i < n; i++) {\n            \n            sum += nums[i];\n            \n            map.put(nums[i], map.getOrDefault(nums[i], 0) + 1);\n        }\n        \n        int maxOutlier = -1001;\n        \n        for(int i = 0; i < n; i++) {\n            \n            int remainingSum = sum - nums[i];\n            \n            map.put(nums[i], map.get(nums[i]) - 1);\n            \n            if(remainingSum % 2 == 0 && map.getOrDefault(remainingSum / 2, 0) > 0) {\n                \n                maxOutlier = Math.max(maxOutlier, nums[i]);\n            }\n            \n            map.put(nums[i], map.get(nums[i]) + 1);\n        }\n        \n        return maxOutlier;\n        \n    }\n}\n```
[]