50-Powx-N
Sat 17 May 2025
https://leetcode.com/problems/powx-n
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def myPow(self, x: float, n: int) -> float:
if n == 0:
return 1
if n < 0:
return 1 / self.myPow(x, -n)
if n & 1:
return x * self.myPow(x, n - 1)
return self.myPow(x * x, n // 2)
new Solution().myPow()
Score: 5
Category: leetcode