C++ Math Check Each Idx For Outlier
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\n#include <bits/stdc++.h>\nusing namespace std;\nclass Solution {\npublic:\n    int getLargestOutlier(vector<int>& nums) {\n        int n = nums.size();\n        int sum = accumulate(nums.begin(), nums.end(), 0);\n        unordered_map<int, int> freq;\n        for(int num : nums) ++freq[num];\n        int mx = -1001;\n        for(int i = 0; i < n; i++) {\n        \tsum -= nums[i]; --freq[nums[i]];\n            // One of them is the sum so\n            // [a, b, c, .., (a+b+c+..)]\n            // sum = 2*(a+b+c+..)\n            // check if (a+b+c+..) exists which is sum/2\n        \tif(sum % 2 == 0 && freq[sum / 2] > 0) mx = max(mx, nums[i]);\n\n        \tsum += nums[i]; ++freq[nums[i]];\n        }\n        return mx;\n    }\n};\n```
['Math', 'C++']