LeetCodemaxarea-maximal-rectangle:最大矩形

时间:2024-07-27 01:47:33
【文件属性】:

文件名称:LeetCodemaxarea-maximal-rectangle:最大矩形

文件大小:1KB

文件格式:ZIP

更新时间:2024-07-27 01:47:33

系统开源

力扣最大面积最大矩形 给定一个由 0 和 1 填充的二维二进制矩阵,找到仅包含 1 的最大矩形并返回其面积。 Example: Input: [ ["1","0","1","0","0"], ["1","0","1","1","1"], ["1","1","1","1","1"], ["1","0","0","1","0"] ] Output: 6 执行 : class Solution { public int largestRectangleArea ( int [] heights ) { Stack< Integer > stack = new Stack<> (); int maxArea = 0 ; int index = 0 ; while (index < heights . length) { if (stack . empty() || heights[index] >= heights[stack . peek()]) { stack . push(index ++ ); } else { int top = stack . pop(); int width =


【文件预览】:
maximal-rectangle-master
----README.md(2KB)

网友评论