classSolution{ //time complexity logn publicdoublemyPow(double x, int n){ if ( x == 0 || x == 1) return x; if (n < 0) return1 / pow(x, -n); return pow(x, n); } privatedoublepow(double x, int n){ if (n == 0) return1; double y = pow(x, n / 2); if (n % 2 == 0) return y * y; elsereturn y * y * x; } }