Skip to content

Commit c3e3ea5

Browse files
authored
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy