50. Pow\(x, n\)
2019-04-28
50. Pow(x, n)
Implement pow(_x_, _n_), which calculates _x_ raised to the power _n_ (xn).
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 [−231, 231 − 1]
Code:
1 | class Solution(object): |