Dsa
Bit Manipulation
Medium
Count Power of Two Gaps
Given an integer N, count how many pairs of integers (a, b) exist such that both are powers of two and the absolute difference between them is equal to N. Output the number of such pairs.
Example:
Input:
3
Output:
0
(There are no two powers of two that differ by 3.)
Key concepts
bit_manipulationgaps
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