题目描述:
输入输出Demo:
height中的数字对应着一个柱形图:横坐标是height数字的索引值 +1;高度是height数组中的数字;求的是这些柱形图中最大矩形的面积
解析:在LeetCode上本题属于Medium难度。这道题也是一道典型的动态规划题目,本题属于高频题!!
//双指针class Solution {public int maxArea(int[] height) {if (height.length == 0) {return 0;}int left = 0, right = height.length - 1;int maxArea = 0;while (left < right) {int currArea=(right-left)*Math.min(height[left],height[right]);maxArea=Math.max(currArea,maxArea);if(height[left] <= height[right]){left++;}else{right--;}}return maxArea;}}
