. - 力扣(LeetCode)
思路分析:
利用函数的单调性解决这道题两端取最小,最小的往里找就是高不变或者缩小 宽减少 一定是减小的因此这题可以使用左右指针实现
public int maxArea(int[] height) {int left = 0;int right = height.length - 1;int max = 0;int v = 0;while (left != right){if (height[left] > height[right]){v = height[right] * (right - left);right--;}else {v = height[left] * (right - left);left++;}if (max < v){max = v;}}return max;}