Skip to content

Bit Manipulation

Table of Contents

2595. Number of Even and Odd Bits

  • LeetCode | LeetCode CH (Easy)

  • Tags: bit manipulation

  • Topic: Bit Manipulation
  • Difficulty: Easy

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].

Comments