326 Power of Three
326. Power of Three
1. Question
2. Implementation
class Solution {
public boolean isPowerOfThree(int n) {
while (n > 0 && n % 3 == 0) {
n = n/3;
}
return n == 1;
}
}3. Time & Space Complexity
Last updated