We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents cc80eb2 + 5d74d22 commit 56a8302Copy full SHA for 56a8302
3370. Smallest Number With All Set Bits
@@ -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