diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/3827. Count Monobit Integers.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/3827. Count Monobit Integers.py" new file mode 100644 index 00000000..97c60762 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/3827. Count Monobit Integers.py" @@ -0,0 +1,17 @@ +class Solution: + def countMonobit(self, n: int) -> int: + def is_monobit(num): + binary = bin(num)[2:] + base = binary[0] + for b in binary: + if b != base: + return False + return True + + ans = 0 + for i in range(n+1): + ans += is_monobit(i) + return ans + + +