2595. Number of Even and Odd Bits 發表於 2023-03-19 | 分類於 leetcode problemsolution12345678910111213class Solution {public: vector<int> evenOddBit(int n) { vector<int> ret(2,0); int idx = 0; while(n){ ret[idx%2]+=n&1; n>>=1; idx++; } return ret; }}; analysis time complexity O(logn) space complexity O(1)