We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bbcff29 commit c9093adCopy full SHA for c9093ad
50-Pow(x, n)
@@ -0,0 +1,11 @@
1
+class Solution:
2
+ def myPow(self, x: float, n: int) -> float:
3
+ def helper(x, n):
4
+ if x == 0: return 0
5
+ if n == 0: return 1
6
+
7
+ res = helper(x * x, n // 2)
8
+ return x * res if n % 2 else res
9
10
+ res = helper(x, abs(n))
11
+ return res if n >= 0 else 1 / res
0 commit comments