SIMPLEST SOLUTION POSSIBLE || BINARY SEARCH :-
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\ni first started with sorting the array ,so that i can use binary search .
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\ni first started with sorting the array ,so that i can use binary search .\n```\nsort(nums.begin(),nums.end());\n```\nnext , i calculated the sum of the complete array .\n```\nint s = 0; // sum of the complete array\n        int n = nums.size();\n        int ans = INT_MIN;\n        for(int i = 0;i<n;i++){\n            s+=nums[i];\n        }\n```\nthen , i iterate the complete array and for each element i was looking for outlier which must be equal to the (sum of array - 2* nums[i]). \nthen i applied binary search for the rest parts of the array that means , for previous part(from 0 to i-1) and the next part(from i+1 to n-1) .\n```\nfor(int i = 0;i<n;i++){\n            int x = s-(2*nums[i]); // the outlier must be equal to sum of array - (2* nums[i]).\n            // applying binary search\n            int lo = i+1,hi = n-1;\n            while(lo<=hi){\n                int mid = lo+(hi-lo)/2;\n                if(nums[mid] == x ) {if(x>ans) ans = x; break;}\n                else if(nums[mid] > x) hi = mid-1;\n                else lo = mid+1;\n            }\n            lo = 0;hi = i-1;\n            while(lo<=hi){\n                int mid = lo+(hi-lo)/2;\n                if(nums[mid] == x ) {if(x>ans) ans = x; break;}\n                else if(nums[mid] > x) hi = mid-1;\n                else lo = mid+1;\n            }\n        }\n```\nhere , ans works as the tracker for the largest outlier possible .\n\nplease upvote , i worked damn hard for it . \n\n# Complexity\n- Time complexity: O(NlogN)\n\n- Space complexity:O(1)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int getLargestOutlier(vector<int>& nums) {\n        sort(nums.begin(),nums.end());\n        int s = 0; // sum of the complete array\n        int n = nums.size();\n        int ans = INT_MIN;\n        for(int i = 0;i<n;i++){\n            s+=nums[i];\n        }\n        for(int i = 0;i<n;i++){\n            int x = s-(2*nums[i]); // the outlier must be equal to sum of array - (2* nums[i]).\n            // applying binary search\n            int lo = i+1,hi = n-1;\n            while(lo<=hi){\n                int mid = lo+(hi-lo)/2;\n                if(nums[mid] == x ) {if(x>ans) ans = x; break;}\n                else if(nums[mid] > x) hi = mid-1;\n                else lo = mid+1;\n            }\n            lo = 0;hi = i-1;\n            while(lo<=hi){\n                int mid = lo+(hi-lo)/2;\n                if(nums[mid] == x ) {if(x>ans) ans = x; break;}\n                else if(nums[mid] > x) hi = mid-1;\n                else lo = mid+1;\n            }\n        }\n        return ans;\n    }\n};\n```\n\n![please upvote.png](https://assets.leetcode.com/users/images/fa6b8b84-567e-44f2-b541-7f61b047c373_1733030732.1137238.png)\n
['C++']