class Solution {
public int maxArea(int[] height) {
int len = height.length;
int offset = 0;
int end = len - 1;
int max = 0;
while( offset != end) {
int min = Math.min(height[offset], height[end]);
int temp = min * (end - offset);
if (max < temp) max = temp;
if (min == height[offset]) {
offset++;
} else {
end--;
}
}
return max;
}
}
Time: O(N)
Space: O(1)