package leetcode;

/**
 * https://leetcode.com/problems/maximal-rectangle/
 */
public class Problem85 {
    public int maximalRectangle(char[][] matrix) {
        return 0;
    }

    public static void main(String[] args) {
        Problem85 prob = new Problem85();
        System.out.println(prob.maximalRectangle(new char [][]{
            {'1', '0', '1', '0', '0'},
            {'1', '0', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
            {'1', '0', '0', '1', '0'},
        })); // 6
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -186,16 +186,1224 @@
     
-return 0
+if (matrix == null %7C%7C matrix.length == 0) %7B%0A            return 0;%0A        %7D%0A        int nCols = matrix%5B0%5D.length;%0A        int%5B%5D left = new int%5BnCols%5D;%0A        int%5B%5D right = new int%5BnCols%5D;%0A        int%5B%5D height = new int%5BnCols%5D;%0A        Arrays.fill(right, nCols);%0A        int result = 0;%0A        for (char%5B%5D row : matrix) %7B%0A            int curLeft = 0;%0A            for (int col = 0; col %3C nCols; col++) %7B%0A                if (row%5Bcol%5D == '1') %7B%0A                    left%5Bcol%5D = Math.max(left%5Bcol%5D, curLeft);%0A                    height%5Bcol%5D++;%0A                %7D else %7B%0A                    left%5Bcol%5D = 0;%0A                    curLeft = col + 1;%0A                    height%5Bcol%5D = 0;%0A                %7D%0A            %7D%0A            int curRight = nCols;%0A            for (int col = nCols - 1; col %3E= 0; col--) %7B%0A                if (row%5Bcol%5D == '1') %7B%0A                    right%5Bcol%5D = Math.min(right%5Bcol%5D, curRight);%0A                %7D else %7B%0A                    right%5Bcol%5D = nCols;%0A                    curRight = col;%0A                %7D%0A            %7D%0A            for (int col = 0; col %3C nCols; col++) %7B%0A                result = Math.max(result, (right%5Bcol%5D - left%5Bcol%5D) * height%5Bcol%5D);%0A            %7D%0A        %7D%0A        return result
 ;%0A  

Update problem 85