C++ One Pass Liner Solution | Beats 💯✅
Intuition\n Describe your first thoughts on how to solve this problem. \nTo efficiently solve this problem, we employ a strategy that utilizes a vector seen to 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo efficiently solve this problem, we employ a strategy that utilizes a vector seen to keep track of encountered numbers. Initializing seen with a size of 1001, we anticipate integers ranging from 0 to 1000 inclusively within nums.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. We iterate through each integer x in the nums vector, obtaining its absolute value y using abs(x), and determine whether x is negative or positive.\n2. If x is negative, we update seen[y] using a binary OR operation (|) with 2. If x is positive, we update seen[y] using a binary OR operation with 1.\n3. Upon encountering a number y where seen[y] contains both 1 and 2 (indicating the presence of both -y and y in the vector), we update our maximum k value.\n4.  Finally, we return the maximum k found during the iteration.\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int findMaxK(vector<int>& nums) {\n        vector<int>seen(1001);\n        int k=-1;\n        for(int x:nums){\n            int y=abs(x);\n            if (x<0) seen[y]|=2;\n            else seen[y]|=1;\n            if (seen[y]==3) k=max(k, y);\n        }\n        return k;\n    }\n};\n```
['Bit Manipulation', 'C++']