Beat 100%! O(m*n*logn ) easy solution
Example 1\n\n[0,0,1],\n[1,1,1],\n[1,0,1] \n\nFor every column, we count the the number of continuous 1 by the current position.  the result matrix will be\n\n[0
Example 1\n\n[0,0,1],\n[1,1,1],\n[1,0,1] \n\nFor every column, we count the the number of continuous 1 by the current position.  the result matrix will be\n\n[0,0,1],\n[1,1,2],\n[2,0,3] \n\nNow let\u2019s consider every row. \nFor the first row, we reversely sort the row\nWe got [1,0,0]. It\'s very easy to get the largest matrix for this row. For other rows, we do the same thing.\n\nFor example, for the second row, We reversely sort the row,\n[2,1,1]\nFor the third row, We reversely sort the row,\n[3,2,0]\n\n```\n    public int largestSubmatrix(int[][] A) {\n        \n        int m  = A.length;\n        int n = A[0].length;\n        \n        int[][] sum = new int[m][n];\n        \n        for(int j = 0; j < n; j++){\n            int cnt = 0;\n            for(int i = 0; i < m; i++){      \n                if(A[i][j] == 0){\n                    cnt = 0;\n                    sum[i][j] = 0;\n                }else{\n                    cnt++;\n                    sum[i][j] = cnt;\n                }\n            }\n        }\n        \n        int max = 0;\n        for(int i = 0; i < m; i++){\n            Arrays.sort(sum[i]);\n            for(int j = 0; j < n; j++){\n                int a = (n - j)*sum[i][j];\n                max = Math.max(a, max);\n            }\n        }\n        return max;\n    }
[]