Bitwise AND of Numbers Range
Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.
Bitwise AND of Numbers Range

Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.

Example 1:
Input: {"left":5,"right":7}
Output: 4
Input
arr ={"left":5,"right":7}

Find common prefix of 5 and 7 in binary

Range: [5, 7] | Shifts: 0

left (5):
0
0
0
0
0
1
0
1
right (7):
0
0
0
0
0
1
1
1
Result:
0
0
0
0
0
0
0
0

= 0

Find common prefix by right-shifting both numbers until equal, then left-shift back
Variables
No variables to display
DepthFunction Call
Stack empty
0/3