Here's the solution:
function maxArea(height)
left := 0
right := length of height - 1
maxArea := 0
while left < right
width := right - left
currentHeight := min(height[left], height[right])
currentArea := width × currentHeight
maxArea := max(maxArea, currentArea)
if height[left] < height[right] then
left := left + 1
else
right := right - 1
return maxArea
This runs in time with space. Each pointer moves at most times.