commit a630e067a27b7d4c1b603d92ac2cbb07bbc249cc
parent ddeb5116a28a5787281927daa366ca2ef1f90cbf
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Tue, 21 Feb 2023 21:47:46 +0100
Algorithm II: Day 19
Diffstat:
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/Problems/0201.cpp b/Problems/0201.cpp
@@ -0,0 +1,13 @@
+class Solution {
+public:
+ int rangeBitwiseAnd(int left, int right) {
+ int cnt = 0;
+ while(left != right)
+ {
+ cnt++;
+ left >>= 1;
+ right >>= 1;
+ }
+ return left << cnt;
+ }
+};
diff --git a/README.md b/README.md
@@ -154,6 +154,7 @@ for solving problems.
| 0198 | Medium | [House Robber](Problems/0198.cpp) |
| 0199 | Medium | [Binary Tree Right Side View](Problems/0199.cpp) |
| 0200 | Medium | [Number of Islands](Problems/0200.cpp) |
+| 0201 | Medium | [Bitwise AND of Numbers Range](Problems/0201.cpp) |
| 0202 | Easy | [Happy Number](Problems/0202.cpp) |
| 0203 | Easy | [Remove Linked List Elements](Problems/0203.cpp) |
| 0205 | Easy | [Isomorphic Strings](Problems/0205.cpp) |