Detailed Explanation || O(n) || C++ || Easy and Optimized Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nWe are given an array nums and need to find the largest outlier. An outlier in this con
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe are given an array `nums` and need to find the largest outlier. An outlier in this context is a number in the array such that if it is removed, the sum of the remaining numbers is even and can be split into two equal halves. The goal is to find the largest such outlier.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Calculate the total sum of the array (`tsum`) and store the frequency of each number in the array using a hash map `freq`.\n2. Loop through each number in the array:\n    - For each number, temporarily reduce its frequency.\n    - Calculate the sum of the remaining numbers (`reqdoublesum = tsum - num`).\n    - If the remaining sum is even, check if half of this sum (`reqsum = reqdoublesum / 2`) exists in the frequency map and has a count greater than zero.\n    - If the condition is satisfied, update the result with the maximum of num and the current ans.\n3. Return the largest valid outlier found.\n# Complexity\n- Time complexity: $$O(n)$$.\n    - We loop through the array twice: once for calculating the sum and frequencies, and once for checking each element. This results in a linear time complexity.\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$.\n    - We use a hash map to store the frequencies of the numbers, which requires extra space proportional to the size of the array.\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int getLargestOutlier(vector<int>& nums) {\n        long tsum = 0;\n        unordered_map<int,int> freq;\n        for(auto it: nums){\n            tsum += it;\n            freq[it]++;\n        }\n\n        int ans = INT_MIN;\n        for(auto num: nums){\n            freq[num]--;\n            long reqdoublesum = tsum-num;\n            if(reqdoublesum %2 ==0){\n                int reqsum = reqdoublesum/2;\n                if(freq[reqsum]>0){\n                    ans = max(ans,num);\n                }\n            }\n            freq[num]++;\n        }\n        return ans;\n    }\n};\n```
['Hash Table', 'Counting', 'Enumeration', 'C++']