basically translated https://discuss.leetcode.com/topic/64285/java-o-n-top-solution-with-explanation with some small changes

```
def max_area(height)
n = height.length
left = 0
right = n - 1
max_area = 0
h = 0
while left < right do
h = [height[left], height[right]].min
area = (right - left) * h
max_area = [area, max_area].max
while height[left] <= h && left < right do
left += 1
end
while height[right] <= h && left < right do
right -= 1
end
end
return max_area
end
```