less than 1 minute read

Given two integers start and end, return the bitwise AND of all numbers in [start, end], inclusive.

Constraints

  • 0 ≤ start ≤ end < 2**31

https://binarysearch.com/problems/Bitwise-AND-of-Range-of-Numbers

Examples

Example 1

Input

  • start = 5
  • end = 7

Output

  • answer = 4

Explanation

0101 = 5
0110 = 6
0111 = 7
----
0100 = 4

Solution

Leave a comment