Skip to content

Commit 5792f1b

Browse files
committed
Time: 6 ms (10.07%), Space: 17.9 MB (26.92%) - LeetHub
1 parent eb95901 commit 5792f1b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# time complextiy: O(n)
2+
# space complexity: O(1)
3+
class Solution:
4+
def smallestNumber(self, n: int) -> int:
5+
while True:
6+
if bin(n).count('0') == 1:
7+
return n
8+
n += 1
9+
10+
11+
n = 5
12+
print(Solution().smallestNumber(n))
13+
n = 10
14+
print(Solution().smallestNumber(n))
15+
n = 3
16+
print(Solution().smallestNumber(n))

0 commit comments

Comments
 (0)