class Solution { public int maxArea(int[] height) { //initialize area, most left side and right side int area = 0, l = 0, r = height.length - 1; //as long as left is on the "left" while(l < r) { area = Math.max(area, Math.min(height[l], height[r]) * (r - l)); if(height[l] < height[r]) { l++; } else { r--; } } return area; } }