🔥Beats 90% - No HashTable - O(1) Space | Clean Code | C++ |
Code\n\nclass Solution {\npublic:\n    int findMaxK(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        \n        int left = 0, right = nums.
# Code\n```\nclass Solution {\npublic:\n    int findMaxK(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        \n        int left = 0, right = nums.size() - 1;\n        while (left < right)\n        {\n            if (nums[left] == -nums[right])\n            {\n                return abs(nums[left]);\n            }\n            else if (abs(nums[left]) < abs(nums[right]))\n            {\n                right--;\n            }\n            else\n            {\n                left++;\n            }\n        }\n\n        return -1;\n    }\n};\n```
['C++']