class Solution { //striver dp Q55 public int maximalRectangle(char[][] matrix) { int n = matrix.length , m = matrix[0].length; int max = 0; int dp[] = new int[m]; for(char cols[] : matrix){ for(int i = 0 ;i < cols.length; i++){ if(cols[i] == '1') dp[i]+=1; else dp[i] = 0; } max = Math.max(max , area(dp[])); } return max; } public int area(int arr[]){ //larges area histogram code } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter