题目
Implement pow(x, n), which calculates x
raised to the power n
(x^n)
.
Example 1:
1 | Input: 2.00000, 10 |
Example 2:
1 | Input: 2.10000, 3 |
Example 3:
1 | Input: 2.00000, -2 |
Note:
-100.0 < x < 100.0
n
is a 32-bit signed integer, within the range[−2^31, 2^31 − 1]
思路
Iteration.
代码
1 | class Solution(object): |