题目
注意:二维接雨水,有墙的,有线的,着这个属于线的。
class Solution {
public int maxArea(int[] height) {
if (height.length < 2) {
return 0;
}
int left = 0, right = height.length - 1, res = 0;
while (left < right) {
int tmp = (right - left) * Math.min(height[left], height[right]);
res = Math.max(res, tmp);
if (height[left] <= height[right]) {
++left;
} else {
--right;
}
}
return res;
}
}