Dsa
Bit Manipulation
Medium
Bitwise AND Range
You are given two integers `left` and `right`. Calculate the bitwise AND of all numbers in the inclusive range from `left` to `right`. Print the result.
Input:
Two space-separated integers `left` and `right` (0 ≤ left ≤ right ≤ 10^9).
Output:
A single integer, which is the bitwise AND of all integers from `left` to `right`.
Example:
Input:
5 7
Output:
4
Explanation: The numbers are 5 (101), 6 (110), and 7 (111). Their bitwise AND is 4 (100).
Key concepts
bit_manipulationrangeand
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