💯Faster🔥Lesser✅🧠Detailed Approach🎯Two Pointer🔥Python🐍
Intuition\n Describe your first thoughts on how to solve this problem. \nfor pairing the negative and positive pairs used the logic\n>sum of x and -x is zero\n#
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n**for pairing the negative and positive pairs used the logic**\n>sum of x and -x is zero\n# Approach\n<!-- Describe your approach to solving the problem. -->\n**1) Sorted the array first**\nExample:\n>nums          =  [-10,8,6,7,3,-2,-3]\nnums.sort()  >> [-10,-3,-2,3,6,7,8]\nhence negative numbers in the left side and positive of the right\n\n**2) Took 2 points i and j**\n>i represents elements with negative indexes\nj represents elements with positive indexes\n\n**3) Find the sum of nums[i] and nums[j]**\n>**case:1** if sum is 0 means -x and x presents in the array, return x >>> ie here, nums[ j ]\n>> returned nums[ j ] will be the largest Positive Integer That Exists With Its Negative since the array is sorted\n\n>**case:2** if sum < 0 implies more negative numbers is there \n>>hence move negative pointer\n>> i += 1\n\n>**case:3** if sum > 0 implies more positive numbers is there \n>>hence move positive pointer\n>> j -= 1\n\n\n\n# Complexity\n- Time complexity:O(log(n))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity:O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\nclass Solution:\n    def findMaxK(self, nums: List[int]) -> int:\n        i = 0\n        j = len(nums)-1\n        nums.sort()\n        while i<j:\n            res = nums[i]+nums[j]\n            if res==0:\n                return nums[j]\n            elif res>0:\n                j -= 1\n            else:\n                i += 1\n        return -1\n        \n```
['Python3']