AND In Range | Bit magic


AND In Range

Difficulty: MediumAccuracy: 48.03%Submissions: 10K+Points: 4

You are given two integers l and r. Find the result after applying the series of Bitwise AND ( & ) operation on every natural number between the range l to r (including both).

Examples:

Input: l = 8, r = 13
Output: 8
Explanation: 
8 AND 9 AND 10 AND 11 AND 12 AND 13 = 8.
Input: l = 2, r = 3
Output: 2
Explanation: 2 AND 3 = 2.

Constraints:
1 ≤ l ≤ r ≤ 109

Expected Complexities
Topic Tags
Related Articles
If you are facing any issue on this page. Please let us know.

Comments

Popular Posts