[Java/C++/Python] HashMap
Explanation\nCount elements total sum and frequence count.\nFor each a as the sum,\nwe check outlier = total - a - a,\nif outlier exists,\nwe update res = max(r
# **Explanation**\nCount elements `total` sum and frequence `count`.\nFor each `a` as the sum,\nwe check `outlier = total - a - a`,\nif `outlier` exists,\nwe update `res = max(res, outlier)`.\n\nfinally return result `res`.\n\n# **Complexity**\nTime `O(n)`\nSpace `O(n)`\n<br>\n\n```Java [Java]\n    public int getLargestOutlier(int[] A) {\n        Map<Integer, Integer> count = new HashMap<>();\n        int total = 0, res = Integer.MIN_VALUE;\n        for (int a : A) {\n            total += a;\n            count.put(a, count.getOrDefault(a, 0) + 1);\n        }\n        for (int a : A) {\n            int outlier = total - a - a;\n            if (count.getOrDefault(outlier, 0) > (outlier == a ? 1 : 0)) {\n                res = Math.max(res, outlier);\n            }\n        }\n        return res;\n    }\n```\n\n```C++ [C++]\n    int getLargestOutlier(vector<int>& A) {\n        unordered_map<int, int> count;\n        int total = 0, res = INT_MIN;\n        for (int a : A) {\n            total += a;\n            count[a]++;\n        }\n        for (int a : A) {\n            int outlier = total - a - a;\n            if (count[outlier] > (outlier == a)) {\n                res = max(res, outlier);\n            }\n        }\n        return res;\n    }\n```\n\n```py [Python3]\n    def getLargestOutlier(self, A: List[int]) -> int:\n        total = sum(A)\n        count = Counter(A)\n        res = -inf\n        for a in A:\n            outlier = total - a - a\n            if count[outlier] > (outlier == a):\n                res = max(res, outlier)\n        return res\n```\n
['C', 'Python', 'Java']