Q55 Maximal Rectangle - LeetCode 85

PHOTO EMBED

Sat Sep 09 2023 16:44:17 GMT+0000 (Coordinated Universal Time)

Saved by @Ayush_dabas07

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
    }
}
content_copyCOPY

https://leetcode.com/problems/maximal-rectangle/