Apart from coding and design interview questions, this page contains updates on my learnings with Java. It helps me organize my learning. Read about my future self here : https://siliconvalleystories.blogspot.com/
public class Solution { public double pow(double x, int n) { if(n == 0) return 1; if(n<0){ n = -n; x = 1/x; } return (n%2 == 0) ? pow(x*x, n/2) : x*pow(x*x, n/2); }
}
No comments:
Post a Comment