Dsa
Bit Manipulation
Easy
Count Power of Two in Range
Given two integers `L` and `R`, inclusive, count how many numbers in the range are powers of two.
Input:
- Two space-separated integers `L` and `R` (1 <= L <= R <= 1000000)
Output:
- Output a single integer which is the count of powers of two within the range.
Example:
Input:
1 16
Output:
5
Explanation: The powers of 2 in this range are: 1, 2, 4, 8, 16.
Key concepts
bit_manipulationpowerscounting
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