This commit is contained in:
parent
6be95b9fc0
commit
807b1a2d7e
1 changed files with 11 additions and 0 deletions
11
medium/check_if_number_is_a_sum_of_powers_of_three.py
Normal file
11
medium/check_if_number_is_a_sum_of_powers_of_three.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three
|
||||
|
||||
class Solution:
|
||||
def checkPowersOfThree(self, n: int) -> bool:
|
||||
while n > 0:
|
||||
if n % 3 == 2:
|
||||
return False
|
||||
n //= 3
|
||||
return True
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue