[Link] https://leetcode.com/problems/container-with-most-water/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Solution {
public int maxArea(int[] height) {
int start = 0, end = height.length - 1, max = 0;
while(start < end) {
max = Math.max(max, (end - start) * Math.min(height[end], height[start]));
if(height[start] < height[end]) { // 1 3
start++;
} else {
end--;
}
}
return max;
}
}