#2595
Number of Even and Odd Bits
newbie · 275 · lc easy +19 · 73.4% accepted · 371 likes · top 84%
Description
Given a positive integer n, examine its binary representation where bits are indexed from right starting at 0. Count the number of set bits at even positions (even) and at odd positions (odd). Return [even, odd].
Code
1
2
3