Leetcode 50 Solution
This article provides solution to leetcode question 50 (powx-n)
Access this page by simply typing in "lcs 50" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/powx-n
Solution
class Solution:
def myPow(self, x: float, n: int) -> float:
if n < 0:
return 1 / self.myPow(x, -n)
elif n == 0:
return 1
if n % 2 == 0:
return self.myPow(x * x, n // 2)
else:
return self.myPow(x * x, n // 2) * x