#2595

Number of Even and Odd Bits

easy · 73.4% accepted · 371 likes · top 84%

bit manipulation

⊣ practice⊣ open on leetcode ↗

Description

You are given a positive integer n.

Let even denote the number of even indices in the binary representation of n with value 1.

Let odd denote the number of odd indices in the binary representation of n with value 1.

Note that bits are indexed from right to left in the binary representation of a number.

Return the array [even, odd].

Solution