Easy Solution || C++
Intuition\nThe code seems to be counting the number of 1s in the binary representation of a given integer n, and categorizing them into two groups based on thei
# Intuition\nThe code seems to be counting the number of 1s in the binary representation of a given integer `n`, and categorizing them into two groups based on their position - even or odd.\n\n# Approach\nThe approach iterates over the binary representation of the input integer `n`, counts the number of 1s at even and odd positions, and then returns a vector containing these counts.\n\n# Complexity\n- Time complexity: $$O(log n)$$ - The algorithm iterates over the binary representation of the input integer `n`, which has a length of $$\\log n$$.\n- Space complexity: $$O(1)$$ - The space complexity is constant as the algorithm uses only a fixed number of variables regardless of the input size.\n\n# Code\n```cpp\nclass Solution {\npublic:\n    vector<int> evenOddBit(int n) {\n        int bit;\n        int position = 0;\n        int even = 0;\n        int odd = 0;\n        vector<int> ans;\n        while (n != 0){\n            bit = n & 1;\n            if (bit == 1){\n                if (position % 2 == 0){     // even positions\n                    even++;\n                }\n                else{\n                    odd++;\n                }\n            }\n            position++;\n            n = n >> 1;\n        }\n        ans.push_back(even);\n        ans.push_back(odd);\n        return ans;\n    }\n};\n```\n
['Bit Manipulation', 'C++']