Skip to content

Commit 2cdc5d1

Browse files
Container With Most Water Solution added (#36)
Co-authored-by: Gourav Rusiya <[email protected]>
1 parent 1c39def commit 2cdc5d1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Python/container_with_most_water.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution(object):
2+
def maxArea(self, height):
3+
"""
4+
:type height: List[int]
5+
:rtype: int
6+
"""
7+
8+
#print(height)
9+
start=0
10+
end=len(height)-1
11+
max_area=0
12+
curr_area=0
13+
while(start!=end):
14+
if(height[start]<height[end]):
15+
curr_area=height[start]*(end-start)
16+
start+=1
17+
else:
18+
curr_area=height[end]*(end-start)
19+
end-=1
20+
if(curr_area>max_area):
21+
max_area=curr_area
22+
print(curr_area)
23+
return max_area

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Check out ---> [Sample PR](https://github.com/codedecks-in/LeetCode-Solutions/pu
9393
| 119 | [Pascal's Triangle II](https://leetcode.com/problems/pascals-triangle-ii) | [Python](./Python/pascals-triangle-ii.py) | _O(N^2)_ | _O(K)_ | Easy | | |
9494
| 1480 | [Running Sum of 1d Array](https://leetcode.com/problems/running-sum-of-1d-array/) | [Java](./Java/running-sum-of-1d-array.java) | _O(N)_ | _O(N)_ | Easy | Simple sum | |
9595
| 42 | [Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/) | [Python](./Python/trapping_rain.py) | _O(N^2)_ | _O(N)_ | Hard | Array | |
96+
| 11 | [Container with Most Water](https://leetcode.com/problems/container-with-most-water/) | [Python](./Python/container_with_most_water.py) | _O(N)_ | _O(N)_ | Medium | Array Two Pointers| |
9697

9798

9899
<br/>

0 commit comments

Comments
 (0)