2595. Number of Even and Odd Bits
You are given a positive integer
n
.Let
even
denote the number of even indices in the binary representation ofn
(0-indexed) with value1
.Let
odd
denote the number of odd indices in the binary representation ofn
(0-indexed) with value1
.Return an integer array
answer
whereanswer = [even, odd]
.
1 | class Solution { |