Check if Number is a Sum of Powers of Three | Leetcode 1780