1780. Check if Number is a Sum of Powers of Three

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1780

class Solution:
    def checkPowersOfThree(self, n: int) -> bool:
        while n:
            if n % 3 > 1:
                return False
            n //= 3
        return True