Preview:
class Solution {
public:
    double my_Pow(double x, long n)
    {
        if(n==0) return 1.0;
        if(n==1) return x;
        if(n<0) return my_Pow(1/x, -n);
        double result=my_Pow(x*x, n/2);
        if(n%2==1) result*=x;
        return result;
    }
    
    double myPow(double x, int n) {
        return my_Pow(x, n);
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter