A building's elevator security system assigns every floor f an access code equal to f itself. During a nightly maintenance window covering floors m through n inclusive, the system computes a combined lockout mask by taking the bitwise AND of every floor's access code in that window.
Given m and n, compute this AND of all integers from m to n inclusive.
Line 1: two space-separated integers m n.
A single integer: the bitwise AND of every integer in [m, n].
Example 1
Input
5 7
Expected
4
Explanation
5 AND 6 AND 7 = 4.
Example 2
Input
8 8
Expected
8
Explanation
Only floor 8 is in the window, so the result is just 8.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →