Skip to content

Commit 5bf5394

Browse files
Merge pull request #1956 from CodingTestStudy2/최원준
[최원준] Day02
2 parents ac19711 + fd0fae7 commit 5bf5394

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution:
2+
def countMonobit(self, n: int) -> int:
3+
def is_monobit(num):
4+
binary = bin(num)[2:]
5+
base = binary[0]
6+
for b in binary:
7+
if b != base:
8+
return False
9+
return True
10+
11+
ans = 0
12+
for i in range(n+1):
13+
ans += is_monobit(i)
14+
return ans
15+
16+
17+

0 commit comments

Comments
 (0)