C++ | Halwa Solution 😌 | 100% faster
\n\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n
\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> evenOddBit(int n) {\n        int even=0, odd=0, index=0;\n        while(n){\n            if(n&1==1){\n                (index%2)==0?even++:odd++;\n            }\n            index++;\n            n = n>>1;\n        }\n        vector<int>ans;\n        ans.push_back(even);\n        ans.push_back(odd);\n        return ans;\n    }\n};\n \n```
['C++']