Hash table solution
Approach\n Describe your approach to solving the problem. \nThe idea is to use a hash table for constant-time element lookup. We iterate through the array, and 
# Approach\n<!-- Describe your approach to solving the problem. -->\nThe idea is to use a hash table for constant-time element lookup. We iterate through the array, and if there exists a negative counterpart $-num$ for the current element $num$ in the hash table, we update the answer.\n\nThis approach provides fast lookup and efficiently finds the maximum value.\n\n# Complexity\n- Time complexity: $O(n)$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $O(n)$ additional memory for hash table.\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int findMaxK(std::vector<int>& nums) {\n        int result = -1;\n        std::unordered_set<int> set;\n        for (const auto& num: nums) {\n            if (set.find(-num) != set.end() && abs(num) > result) {\n                result = abs(num);\n            }\n            set.insert(num);\n        }\n        return result;\n    }\n};\n```\n\nMost of my solutions are in [C++](https://github.com/drgavrikov/leetcode-cpp) and [Kotlin](https://github.com/drgavrikov/leetcode-jvm) on my [Github](https://github.com/drgavrikov).
['Hash Table', 'Memoization', 'C++']