GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Create 201_bitwise_and_of_numbers_range.cpp (#29) · anandanthony/leetcode@e0168c2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • cpp
    • 201_bitwise_and_of_numbers_range.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cpp/201_bitwise_and_of_numbers_range.cpp‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/** time complexity : O(logN). N = min(m, n) **/
2+
3+
class Solution {
4+
public:
5+
int rangeBitwiseAnd(int m, int n) {
6+
int cnt = 0;
7+
while(m < n) {
8+
m = m >> 1;
9+
n = n >> 1;
10+
cnt++;
11+
}
12+
return n<<cnt;
13+
}
14+
};

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.