Dsa
Bit Manipulation
Medium
Reversed Bits Count
For a given integer N, count how many integers exist from 1 to N whose binary representation has their bits reversed, resulting in a number that is still less than N. Output the count of such integers.
Example:
Input:
8
Output:
2
(For N=8, the numbers 1 (1 -> 1) and 2 (2 -> 2) fit the criteria, as their reverse binary forms are within the range.)
Key concepts
bit_manipulationcounting
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now