```
public class Solution
{
public int MaxArea(int[] height)
{
if (height.Length < 2) return 0;
var left = 0;
var right = height.Length - 1;
var globalArea = 0;
while(left < right)
{
var localArea = Math.Min(height[left], height[right]) * (right - left);
globalArea = Math.Max(localArea, globalArea);
if (height[left] > height[right])
{
right--;
}
else if (height[left] < height[right])
{
left++;
}
else
{
left++;
right--;
}
}
return globalArea;
}
}
```