Simple solution faster than 100%.
If you are new to bit manipulation solve is question first.\nhttps://leetcode.com/problems/number-of-1-bits/\n\nTC: O(N);\nSC: O(1);\n\n\n# Code\n\nclass Soluti
If you are new to bit manipulation solve is question first.\nhttps://leetcode.com/problems/number-of-1-bits/\n\nTC: O(N);\nSC: O(1);\n\n\n# Code\n```\nclass Solution {\n    public int[] evenOddBit(int n) {\n        int flag = 1; //when flag = 1, index is even. Since it is 0 based indexing.\n        int even = 0;\n        int odd = 0;\n        while(n != 0){\n            int bit = n & 1;\n            if(bit == 1 && flag == 1){\n                even++;\n            }\n            if(bit == 1 && flag != 1){\n                odd++;\n            }\n            flag = Math.abs(flag - 1); //toggle the state of flag.\n            //if flag is 1 it will become 0, and if flag is 0 then it will become 1.\n            \n            n = n >>> 1; \n        }\n        return new int[]{even, odd};\n    }\n}\n```
['Bit Manipulation', 'Java']