Leetcode: Pow(X,n)
Naive thinking is just multiple X for n times, but this is absolutely not this question wants.
We need to make use of the calculation result in previous steps, since X^n = X^n/2 * X^n/2
What if n is odd? Then we need to multiple X one more times.
|
|