Intuition

Use two pointers, starting at the edges.

Approach

Use two pointer, starting at the edge. Always move the pointer with less height

Complexity

  • Time complexity: O(n)

  • Space complexity: O(1)

Code

print(1)class Solution(object):
    def maxArea(self, height):
        """
        :type height: List[int]
        :rtype: int
        """

        start = 0
        end = len(height)-1

        maxVolume = -1
        while start<end:           
            h = min(height[start], height[end])
            maxVolume = max(maxVolume, (end - start) * h)
            if height[start] < height[end]:
                start += 1
            else:
                end -= 1
        
        return maxVolume