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
Explanation: In binary, 5 = 101, 6 = 110 and 7 = 111. Only the leading 1 bit is set in all three numbers, so 5 & 6 & 7 = 100 = 4.
Example 2
Input: left = 0, right = 0
Output: 0
Explanation: The range contains only 0, so the AND is 0.
Example 3
Input: left = 1, right = 2147483647
Output: 0
Explanation: The range includes both 1 (binary 01) and 2 (binary 10), which share no set bits. Once the AND reaches 0 it stays 0, so the answer is 0.
ANDing an entire range zeroes out every bit that ever flips within it. The only bits that survive are the leading bits that are identical in left and right — their common binary prefix. Shift both right until they're equal, then shift the shared value back.
Run checks all cases above. Submit evaluates all test cases.