update on LeetcodeSolve
swadhinbiswas committed 1 years ago
e22678e
1 parent f4aa113
commit e22678e
3 files changed
+17 -0
Showing 3 changed files+17-0
▼121. Best Time to Buy and Sell Stock.py
+2-0
| @@ -0,0 +1,2 @@ | ||
1 | +class Solve: | |
2 | + | |
0 | 3 | |
▼121.Leetcode.py
+2-0
| @@ -0,0 +1,2 @@ | ||
1 | +class Solve: | |
2 | + def m | |
0 | 3 | |
▼50. Pow(x, n).py
+13-0
| @@ -0,0 +1,13 @@ | ||
1 | +class Solution: | |
2 | + | |
3 | + def myPow(self, x: float, n: int) -> float: | |
4 | + def helper(x,n): | |
5 | + if n==0:return 1 | |
6 | + if x==0:return 0 | |
7 | + res=helper(x*x,n//2) | |
8 | + return x*res if n%2!=0 else res | |
9 | + res=helper(x,abs(n)) | |
10 | + return res if n>=0 else 1/res | |
11 | + | |
12 | + | |
13 | + | |
0 | 14 | |