✅Beats 96% |🔥O(n) time and space complexity 🔥|🔥 Easy, Fast and Efficient using HashSet🔥🔥1 pass
Intuition\nTo find the largest positive integer k such that -k also exists in the array, we can make array into hashset and iterate through the hashset and chec
# Intuition\nTo find the largest positive integer k such that -k also exists in the array, we can make array into hashset and iterate through the hashset and check if the negative of each number exists in the hashset.\n\n# Approach\nUse HashMap \n\n# Complexity\n- Time complexity:\nO(n) time complexity and only one for loop\n\n- Space complexity:\nO(n) Space complexity for store array into Hash-Table\n\n# Code\n```\nclass Solution {\n    public int findMaxK(int[] nums) {\n        int[] arr = new int[1001];\n        int ind;\n        int max= -1;\n\n        for(int i=0; i<nums.length;i++){\n            ind = Math.abs(nums[i]);\n            if(arr[ind]!=0 && (arr[ind]+nums[i])==0 && Math.abs(nums[i])>max){  \n                max=Math.abs(nums[i]); \n            } \n            else if(arr[ind]!=nums[i]){\n                arr[ind] = nums[i]; \n            }\n        }\n        return max;\n    }\n}\n```
['Java']