Problem Solving/LeetCode
Today's Challenge
fabichoi
2022. 8. 24. 23:45
https://leetcode.com/problems/power-of-three/submissions/
Power of Three - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
오늘도 easy 난이도 문제.
생각보다 따질 조건들이 몇개 있음.
class Solution:
def isPowerOfThree(self, n: int) -> bool:
if n == 1:
return True
if n < 3:
return False
while n > 1:
if n % 3 != 0:
return False
n //= 3
return True
반응형