update
swadhinbiswas committed 2 years ago
52d2041
1 parent 2cf2dbd
commit 52d2041
2 files changed
+33 -0
Showing 2 changed files+33-0
▼Container With Most Water.py
+29-0
| @@ -0,0 +1,29 @@ | ||
1 | +#Broutforce method | |
2 | +from typing import List | |
3 | +class Solution: | |
4 | + def maxArea(self, height: List[int]) -> int: | |
5 | + | |
6 | + if len(height)<=2: | |
7 | + return height[0]*1 | |
8 | + | |
9 | + | |
10 | + else: | |
11 | + res=0 | |
12 | + l,r=0,len(height)-1 | |
13 | + | |
14 | + while l<r: | |
15 | + area=(r-1)*min(height[l], height[r]) | |
16 | + res=max(res, area) | |
17 | + | |
18 | + if height[l]<height[r]: | |
19 | + l+=1 | |
20 | + else: | |
21 | + r-=1 | |
22 | + | |
23 | + return res | |
24 | + | |
25 | + | |
26 | +height =[1,1] | |
27 | +soluction=Solution() | |
28 | +x=soluction.maxArea(height) | |
29 | +print(x) | |
0 | 30 | |
▼Toph.co/MSIS!.py
+4-0
| @@ -0,0 +1,4 @@ | ||
1 | + | |
2 | +class Solve: | |
3 | + def soluction(self,list1:List)->int: | |
4 | + pass | |
0 | 5 | |