Hash Map and Counter Approach || Python3
Hash Map and Counter Approach:\n\n# Intuition\n- The problem involves finding the largest "outlier" number where the remaining sum of elements divided by 2 equa
# Hash Map and Counter Approach:\n\n# Intuition\n- The problem involves finding the largest "outlier" number where the remaining sum of elements divided by 2 equals the number itself.\n\n# Approach\n- Use a `Counter` to keep track of the frequency of each number in `nums`.\n- Calculate the sum of the list (`s`).\n- Iterate over each element in `nums`:\n  - Compute the potential "outlier" by subtracting the current element from `s`.\n  - If the outlier condition holds and the count of the element is 1, skip it.\n  - Otherwise, check if `outlier / 2` exists in the `Counter` and update the maximum value.\n- Return the maximum outlier found, or -1 if no valid outlier is found.\n\n# Complexity\n- Time complexity: $$O(n)$$\n- Space complexity: $$O(n)$$\n\n# Code\n```python\nfrom typing import List\nfrom collections import Counter\n\nclass Solution:\n    def getLargestOutlier(self, nums: List[int]) -> int:\n        maxi = float(\'-inf\')\n        numCount = Counter(nums)\n        s = sum(nums)\n        \n        for i in nums:\n            outlier = s - i\n            if outlier / 2 == i and numCount[i] == 1:\n                continue\n            elif numCount[outlier / 2]:\n                maxi = max(maxi, i)\n        \n        return maxi if maxi != float(\'-inf\') else -1\n
['Python3']