Easy to Understand java solution


  • -2
    Y
    public class Solution {
    public boolean isPowerOfThree(int n) {
        if(n<=0) return false;
        if(n==1) return true;
        if(n%3==0){
            return isPowerOfThree(n/3);
        }
        return false;
    }
    

    }


  • 0
    Y

    easy understanded answer


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.