Beat 93.67% Java solution with a loop version, extensible (work for other power of integer)!!!

  • 0
    public boolean isPowerOfThree(int n) {
        if(n<1 || n==2) return false;
            if(n%3!=0) return false;
            n /= 3;
            if(n%3!=0) return false;
        return true;

Log in to reply

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