LeetCode – Pow(x, n)

Problem: Implement pow(x, n). This is a great example to illustrate how to solve a problem during a technical interview. The first and second solution exceeds time limit; the third and fourth are accepted. Java Solution public double myPow(double x, int n){ if(n==0) return 1;   if(n<0){ return 1/helper(x, -n); }   double v = … Read more