Skip to content

Commit 56a8302

Browse files
authored
Create 3370. Smallest Number With All Set Bits (#920)
2 parents cc80eb2 + 5d74d22 commit 56a8302

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public:
3+
int smallestNumber(int n) {
4+
int x = 1;
5+
while (x < n) {
6+
x = (x << 1) + 1;
7+
}
8+
return x;
9+
}
10+
};

0 commit comments

Comments
 (0)