From d8d82396e3ee33b3d1e3b454ca113884cefead1f Mon Sep 17 00:00:00 2001 From: ImAlpha Date: Thu, 21 Sep 2023 21:03:01 -0700 Subject: [PATCH] Completes 52/61 test cases --- .../11_Container_With_Most_Water.py | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/NeetCodeRoadmap/Two_Pointers/11_Container_With_Most_Water.py b/NeetCodeRoadmap/Two_Pointers/11_Container_With_Most_Water.py index baac1d9..d715426 100644 --- a/NeetCodeRoadmap/Two_Pointers/11_Container_With_Most_Water.py +++ b/NeetCodeRoadmap/Two_Pointers/11_Container_With_Most_Water.py @@ -1,5 +1,24 @@ -def maxArea(self, height): +def maxArea(height): """ :type height: List[int] :rtype: int - """ \ No newline at end of file + """ + n = len(height) + container = [] + + # Handle edge-case + if n == 2: + return min(height) + + for i in range(n): + for j in range(i+1,n): + index = min(height[i], height[j]) + dist = j-i + container.append(index*dist) + return max(container) + # return container + +print(maxArea([1,8,6,2,5,4,8,3,7])) #Output: 49 +print(maxArea([1,2,1])) #Output: 2 +print(maxArea([1,2])) #Output: 1 +print(maxArea([1,2,4,3])) #Output: 4 \ No newline at end of file