Given a 2D binary matrix filled with 0 's and 1 ' s, find the largest rectangle containing all ones and return to its area.
Problem Solving Ideas:
In the 01 matrix, the maximum area of the 1 sub-matrices is all.
The matrix as a histogram for each line can be converted to the previous question, Java implementation is as follows:
static public int maximalrectangle (char[][] matrix) {if (matrix.length==0| | matrix[0].length==0) return 0;int result=0;int[] dp=new int[matrix[0].length];for (int i=0;i<matrix.length;i++) { for (int j=0;j<matrix[0].length;j++) if (matrix[i][j]== ' 1 ') Dp[j]++;else Dp[j]=0;result=math.max (result, Largestrectanglearea (DP));} return result;} public static int Largestrectanglearea (int[] height) { stack<integer> Stk = new stack<integer> (); int ret = 0; for (int i = 0; I <= height.length; i++) { int h=0; if (i Java for Leetcode 085 maximal Rectangle