Tap here to switch tabs
Problem
Submissions

Problem: Number of Even and Odd Bits

med
30 min
Try to solve the Number of Even and Odd Bits problem.

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

med
30 min
Try to solve the Number of Even and Odd Bits problem.

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