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

1
class Solution {
2
public:
3
bool checkPowersOfThree(int n) {
4
// grinding n down by powers of 3
5
while (n) {
6
if (n % 3 == 2) return false;
7
n /= 3;
8
}
9
return true;
10
}
11
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0