Beginner-friendly || Simple solution with HashMap
Intuition\nLet\'s briefly explain, what problem is:\n- there\'s a list of nums\n- our goal is to find the maximum, that has a negative integer of himself (i.e.,
# Intuition\nLet\'s briefly explain, what problem is:\n- there\'s a list of `nums`\n- our goal is to find **the maximum**, that has a **negative integer of himself** (i.e., 2 and -2 etc)\n\nThe approach is **straighforward**: iterate over `nums` and at each step check, if a particular integer is **a maximum one**, and find it **negative version of himself**.\n\nIf this integer **doesn\'t exist**, simply return `-1`.\n\n# Approach\n1. declare `set` for effective indexing of a **negative version of a current maximum**\n2. declare `ans = -1`\n3. iterate over `nums` and **find a maximum**\n4. return `ans`\n\n# Complexity\n- Time complexity: **O(N)**, for building a set and iterating over `nums`\n\n- Space complexity: **O(N)**, the same for storing `set`.\n\n# Code in Python3\n```\nclass Solution:\n    def findMaxK(self, nums: List[int]) -> int:\n        cache = set(nums)\n        ans = -1\n\n        for num in nums:\n            if -num in cache and num > ans: ans = num\n    \n        return ans\n```\n# Code in TypeScript\n```\nfunction findMaxK(nums: number[]): number {\n    const cache = new Set(nums)\n    let ans = -1\n\n    for (let i = 0; i < nums.length; i++) {\n        const curMax = nums[i]\n\n        if (cache.has(-curMax) && curMax > ans) ans = curMax\n    }\n\n    return ans\n};\n```
['Array', 'Hash Table', 'TypeScript', 'Python3']