diff --git a/LeetCode/Problems/Python/Container With Most Water b/LeetCode/Problems/Python/Container With Most Water new file mode 100644 index 00000000..81a8b698 --- /dev/null +++ b/LeetCode/Problems/Python/Container With Most Water @@ -0,0 +1,21 @@ +class Solution { +public: + int maxArea(vector& height) { + int left = 0; + int right = height.size() - 1; + int maxArea = 0; + + while (left < right) { + int currentArea = min(height[left], height[right]) * (right - left); + maxArea = max(maxArea, currentArea); + + if (height[left] < height[right]) { + left++; + } else { + right--; + } + } + + return maxArea; + } +};