Check if Number is a Sum of Powers of Three LeetCode solution in Python

1
class Solution:
2
def checkPowersOfThree(self, n: int) -> bool:
3
while n > 1:
4
n, r = divmod(n, 3)
5
if r == 2:
6
return False
7
return True

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0