Skip to content

Practice Bitwise AND of Numbers Range

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#201
LeetCode Problem

Bitwise AND of Numbers Range

Problem Statement

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

Source: Bitwise AND of Numbers Range on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
left = 5, right = 7
Output
4

# Example 2

Input
left = 0, right = 0
Output
0

# Example 3

Input
left = 1, right = 2147483647
Output
0

Constraints

0 <= left <= right <= 2^31 - 1

Related LeetCode Problems

Practice more problems similar to Bitwise AND of Numbers Range.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.