Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Bitwise AND of Numbers Range

Medium

Topics
Bit Manipulation

Given two integers a and b with a <= b, return the bitwise AND of all numbers in the inclusive range [a, b].

Example 1

Input:  a = 5, b = 7
Output: 4

Example 2

Input:  a = 0, b = 0
Output: 0

Example 3

Input:  a = 26, b = 30
Output: 24

Constraints

  • 0 <= a <= b <= 2^31 - 1
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access