Tap here to switch tabs
Problem
Submissions

Problem: Number of Even and Odd Bits

Number of Even and Odd Bits counts the set bits in a positive integer by their positions, returning an array with totals for even and odd positions starting at the least significant bit.

Statement

You are given a positive integer n.

Let even denote the number of even indices with a value of 11 in the binary representation of n, indexed starting from 00 at the least significant bit.

Let odd denote the number of odd indices with a value of 11 in the binary representation of n, indexed starting from 00 at the least significant bit.

Return an integer array [ even, odd ].

Constraints:

  • 1≤1 \leq n ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Even and Odd Bits

Number of Even and Odd Bits counts the set bits in a positive integer by their positions, returning an array with totals for even and odd positions starting at the least significant bit.

Statement

You are given a positive integer n.

Let even denote the number of even indices with a value of 11 in the binary representation of n, indexed starting from 00 at the least significant bit.

Let odd denote the number of odd indices with a value of 11 in the binary representation of n, indexed starting from 00 at the least significant bit.

Return an integer array [ even, odd ].

Constraints:

  • 1≤1 \leq n ≤1000\leq 1000