容器盛水问题:https://www.nowcoder.com/practice/31c1aed01b394f0b8b7734de0324e00f?tpId=117&&tqId=35269&rp=1&ru=/ta/job-code-high&qru=/ta/job-code-high/question-ranking
11. 盛最多水的容器
class Solution {
public int maxArea(int[] height) {
int l = 0, r = height.length - 1;
int ans = 0;
while (l < r) {
int area = Math.min(height[l], height[r]) * (r - l);
ans = Math.max(ans, area);
if (height[l] heights[i]) {
//栈顶的高度
int height = heights[stack.removeLast()];
//弹出栈
int width = i - stack.peekLast() - 1;
Area = Math.max(Area, width * height);
}
stack.add(i);
}
return Area;
}
}