Container with Most Water

Problem Summary

(Write in your own words, not copied from LeetCode. This forces comprehension.)

Key Observations

(Patterns, constraints, or hints in the problem statement.)

Why This Works

(Explain the core reason the solution is correct.)

Main Concepts Used

(Mark the CS concepts or algorithms used.)

Time & Space Complexity

Code

class Solution:
    def maxArea(self, height: List[int]) -> int:
        l, r = 0, len(height) - 1
        maxArea = 0

        while l < r:
            currentArea = min(height[l], height[r]) * (r-l)
            maxArea = max(maxArea, currentArea)

            if height[l] < height[r]:
                l += 1
            else:
                r -= 1

        return maxArea