Divide-and-Conquer with helper function. Big-Oh O(log n).

```
public class Solution {
public double myPow(double x, int n) {
return (n < 0) ? 1 / power(x, n): power(x, n);
}
public double power(double x, int n) {
if (n == 0) return 1;
double result = (power(x, n/2));
return (n % 2 == 0) ? result * result:
x * result * result;
}
}
```