Beated 💯% | JAVA | 💪🏻🤟🏻
Intuition\n Describe your first thoughts on how to solve this problem. \nWe can two pointer aproach to find the desired result.\n\n# Approach\n Describe your ap
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe can two pointer aproach to find the desired result.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n> First, I\'ve sorted the **nums**. Then iterated through the **nums** using two pointers ***i*** and ***j***. ***i*** is moving from start to end and j is moving from end to start of **nums**. Compare **nums[i]*(-1)** and **nums[j]**, if equal the we have got the largest desired number as nums[j] else if **nums[j]** is lesser then **i++** else **j--**.\n\nAt the end return -1 if we have not got the result from **for** loop.\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int findMaxK(int[] nums) {\n        Arrays.sort(nums);\n        for(int i=0, j=nums.length-1; i<nums.length-1 && j>=0; ){\n            if(nums[i]*(-1) == nums[j]) return nums[j];\n            else if(nums[i]*(-1) > nums[j]) i++;\n            else j--;\n        }\n\n        return -1;\n    }\n}\n```
['Java']