O(m*n*log(n)) Solution ||
Complexity\n- Time complexity:O(mnlog(n))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n#
# Complexity\n- Time complexity:O(m*n*log(n))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n# Code\n# C++\n```\nclass Solution {\npublic:\n    int largestSubmatrix(vector<vector<int>>& matrix) {\n        for (int i = 0; i < matrix[0].size(); i++){\n            for (int j = 1; j < matrix.size(); j++) \n                if (matrix[j][i]) matrix[j][i] += matrix[j - 1][i];\n\t\t}\n        int ans = 0;\n        for (auto& v : matrix){\n            sort(v.begin(), v.end(), greater <>()); \n            for (int i = 0; i < v.size(); i++) \n                ans = max(ans, v[i] * (i + 1));\n\t\t}\n        return ans;\n    }\n};\n```\n# Java\n```\nclass Solution {\n    public int largestSubmatrix(int[][] matrix) {\n        for(int i = 0; i < matrix[0].length; i++){\n\t\t\tfor(int j = 1; j < matrix.length; j++)\n\t\t\t    if(matrix[j][i] != 0) matrix[j][i] += matrix[j - 1][i];\n\t\t}\n        \n\t\tint ans = 0;\n\t\tfor(int [] v : matrix){\n\t\t\tArrays.sort(v); \n\t\t\tint left = 0, right = v.length - 1;\n            while (left < right) {\n                int temp = v[left];\n                v[left] = v[right];\n                v[right] = temp;\n                left++;\n                right--;\n            }\n\t\t\tfor(int i = 0; i < v.length; i++)\n\t\t\t    ans = Math.max(ans, v[i] * (i + 1));\n\t\t}\n\t\treturn ans;\n    }\n}\n```
['Array', 'Greedy', 'Sorting', 'Matrix', 'C++', 'Java']