Simple Beginner friendly solution || Simple Code||Beats 100% in both time and space.
Intuition\n Describe your first thoughts on how to solve this problem. \n*It maintains a counter for even and odd positions, and updates it based on the value o
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n****`It maintains a counter for even and odd positions, and updates it based on the value of the bit at that position. Finally, it returns a vector containing the count of set bits at even and odd positions.`****\n# Approach\n<!-- Describe your approach to solving the problem. -->\n` It iteratively divides n by 2 to extract each bit from right to left. The index variable is used to keep track of the current bit position. If the current bit is set (i.e., its value is 1), then the counter for even or odd positions is incremented based on the value of the index variable. Finally, the function returns a vector containing the count of set bits at even and odd positions.`\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n`The time complexity of the given code is O(log n), where n is the input integer. This is because the code iteratively divides n by 2 to extract each bit from right to left, which requires log n iterations in the worst case.`\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n`The space complexity of the given code is O(1), as it uses only a constant amount of extra space to maintain the two counters for even and odd positions. `\n# Code\n```\nclass Solution {\npublic:\n    vector<int> evenOddBit(int n) {\n         int even = 0, odd = 0;\n    int index = 0;\n    while (n > 0) {\n        if (n % 2 == 1) {\n            if (index % 2 == 0) {\n                even++;\n            } else {\n                odd++;\n            }\n        }\n        n /= 2;\n        index++;\n    }\n    return {even, odd};\n    }\n};\n```\n**If this is helpful then upvote\uD83D\uDC4D the solution.**
['Math', 'C++']