Runtime 100% | Intuitive aproach
Approach\n Describe your approach to solving the problem. \nFor each cell in column we count how long streak of 1 is above them.\n\nThen we are checking row by 
# Approach\n<!-- Describe your approach to solving the problem. -->\nFor each cell in column we count how long streak of `1` is above them.\n\nThen we are checking row by row, how we can replace columns so they will form the best submatrix of `1` -> we can acomplish it by sorting the row. \nNow we need to check which combination will give us max result, so it becomes easy task when row is sorted -> `int newSubMatrix = row[j] * (rowLen - j);`, where in `row[j]` we have height of submatrix and multiplying it by number of remaining cells on the right of `j` in the row. We are chcecking there which rectangle will have max num of `1`.\n\nYou might doubt why we can just sort row, omitting all ones and zeros above in colums. This is coz we are checking combinations from the top row to the bottom and in each cell now we have the streak from the top.\n\nYou may also optimise code by skipping zeros in the second for loop.\nHave a great day!\n# Code\n```\nclass Solution {\n    public int largestSubmatrix(int[][] matrix) {\n        int rowLen = matrix[0].length;\n        for (int i = 1; i < matrix.length; ++i) {\n            for (int j = 0; j < rowLen; ++j) {\n                if (matrix[i][j] == 1) {\n                    matrix[i][j] += matrix[i - 1][j];\n                }\n            }\n        }\n        int result = 0;\n        for (int [] row : matrix) {\n            Arrays.sort(row);\n            for (int j = 0; j < rowLen; ++j) {\n                int newSubMatrix = row[j] * (rowLen - j);\n                if (result < newSubMatrix) {\n                    result = newSubMatrix;\n                }\n            }\n        }\n        return result;\n    }\n}\n```
['Java']