C++ Solution | 100.00% Faster | 0ms Runtime | Beginner Friendly Optimized !!
IntuitionThe problem involves analyzing the binary representation of an integernand determining how many 1 bits appear at even and odd positions.ApproachComplex
# Intuition
The problem involves analyzing the binary representation of an integernand determining how many 1 bits appear at even and odd positions.

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    vector<int> evenOddBit(int n) {
        vector<int> ans;
        int even = 0, odd = 0;
        while (n > 0) {
            int rem = n % 2;
            ans.push_back(rem);
            n /= 2;
        }
        for (int i = 0; i < ans.size(); i++) {
            if (ans[i] == 1) {
                if (i % 2 == 0) {
                    even++;
                } else {
                    odd++;
                }
            }
        }
        return {even, odd};
    }
};
```
['Math', 'Bit Manipulation', 'Counting', 'C++']