Using Kadane's Algorithm
Just Replace 0 with negative of MAX possible sum in array. And proceed as in the question of finding maximum sum rectangle.\n\nclass Solution {\n    public int 
Just Replace 0 with negative of MAX possible sum in array. And proceed as in the question of finding maximum sum rectangle.\n```\nclass Solution {\n    public int maximalRectangle(char[][] matrix) {\n        int ans = 0, m=matrix.length,n = matrix[0].length,INF = -m*n;\n        for(int j=0;j<n;j++){\n            int[] temp = new int[m];\n            for(int z=j;z<n;z++){\n                for(int c=0;c<m;c++) temp[c]+= matrix[c][z]==\'0\'?INF:1;\n        \n                ans = Math.max(ans,kadaneAlgo(temp));\n            }\n        }\n        return ans;\n    }\n    private int kadaneAlgo(int[] arr){\n        int max = arr[0], local_max = arr[0];\n        for(int i=1;i<arr.length;i++){\n            local_max = Math.max(arr[i],local_max+arr[i]);\n            max = Math.max(local_max,max);\n        }\n        return max;\n    }\n}\n```
['Java']