Solve without sort and in one linear loop
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nWe need to use a HashSet for storage and check each array element for the
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nWe need to use a HashSet for storage and check each array element for the opposite sign in the HashSet.\n\n# Complexity\n- Time complexity:\n $$O(n)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\npublic class Solution {\n    public int FindMaxK(int[] nums) {\n        int mx = 0;\n        int num = 0;\n        HashSet<int> hset = new HashSet<int>();\n\n        foreach(int n in nums)\n        {\n            num = Math.Abs(n);\n\n            if(hset.Contains(n*-1))\n                mx = Math.Max(mx,num);\n            else if(!hset.Contains(n))\n                hset.Add(n);\n        }\n\n        return mx==0?-1:mx;\n    }\n}\n```
['C#']