Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c3e3ea5

Browse files
Update Bitwise AND of Numbers Range
1 parent 060c684 commit c3e3ea5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎Top Interview 150/Bitwise AND of Numbers Range‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Solution {
3232
public:
3333
int rangeBitwiseAnd(int left, int right) {
3434
int shift = 0 ;
35-
while (left < right) {
35+
while (left < right) { // also can use right & (right - 1) to discard the rightmost '1' bit
3636
left >>= 1 ;
3737
right >>= 1 ;
3838
shift++ ;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /