Java solution, 19ms @79.26%


  • 0
    public class Solution {
        public boolean isPowerOfThree(int n) {
           double n_d = (double)n;
           while(n_d >= 3){
               n_d = n_d/3.0;
           } 
           return n_d == 1.0;
        }
    }
    

Log in to reply
 

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