https://leetcode.com/problems/power-of-three/description/
1
2
3
4
5
6
7
8
9
|
import math
def Log3(x):
return (math.log10(x) / math.log10(3))
class Solution:
def isPowerOfThree(self, n: int) -> bool:
if n <= 0:
return False
return (math.ceil(Log3(n)) == math.floor(Log3(n)))
|
cs |
https://sunchol21.tistory.com/1468 와 같은 내용입니다
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2496. Maximum Value of a String in an Array (0) | 2023.01.19 |
---|---|
leetcode 2535. Difference Between Element Sum and Digit Sum of an Array (0) | 2023.01.17 |
leetcode 263. Ugly Number (0) | 2023.01.17 |
leetcode 231. Power of Two (0) | 2023.01.17 |
백준 27219 Робинзон Крузо (0) | 2023.01.16 |
댓글