My java accepted code with 232ms


  • 0
    L

    public class Solution {

         public double myPow(double x, int n) {
       
                         if(n == 0)return 1;
       
                         if(n < 0){
          
                               n = -n;
          
                               x = 1/x;
       
                                    }
       
                         return ((n & 0x1 )== 1)?x*myPow(x*x,n>>1):myPow(x*x,n >>1);
    
                }
    

    }


Log in to reply
 

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