Skip to content

Commit c679f23

Browse files
Bitwise AND of Numbers Range
1 parent f55a273 commit c679f23

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+
2+
3+
int rangeBitwiseAnd(int left, int right){
4+
int count = 0;
5+
while (left != right){
6+
left >>= 1;
7+
right >>= 1;
8+
count++;
9+
}
10+
return left << count;
11+
}

0 commit comments

Comments
 (0)