Container With Most Water - Implementation

Here is the implementation:

function maxArea(height):
    left = 0
    right = height.length - 1
    maxWater = 0

    while left < right:
        width = right - left
        h = min(height[left], height[right])
        maxWater = max(maxWater, width * h)

        if height[left] < height[right]:
            left += 1
        else:
            right -= 1

    return maxWater

This runs in O(n)O(n) time and O(1)O(1) space (excluding input).