Skip to content

Commit d7ccef6

Browse files
Bitwise AND of Numbers Range
1 parent f4a36b5 commit d7ccef6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int rangeBitwiseAnd(int left, int right) {
3+
int count = 0;
4+
while (left != right){
5+
left >>= 1;
6+
right >>= 1;
7+
count++;
8+
}
9+
return left << count;
10+
}
11+
}

0 commit comments

Comments
 (0)