🚀😎 BEATS 100% | MOST EASY APPROACH🔥🔥| C++ | JAVA | PYTHON | JS
Intuition\nUPVOTE IF YOU FOUND THIS HELPFUL !!\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n\n\n Describe your approach to solvi
# Intuition\nUPVOTE IF YOU FOUND THIS HELPFUL !!\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n![Screenshot 2023-11-26 081330.png](https://assets.leetcode.com/users/images/53e71c26-9983-4dbf-9fef-2ca7b5cb1e6d_1700966821.6870956.png)\n\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N*M)\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\n# Code\n```\nclass Solution {\npublic:\n    int largestSubmatrix(vector<vector<int>>& matrix) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(0);\n        cout.tie(0);\n        \n        // Code\n        int n = matrix.size(); // Row Size\n        int m = matrix[0].size(); // Col Size\n\n        int ans = INT_MIN;\n        for(int j = 0; j < m; j++) // Col\n        {\n            for(int i = 1; i < n; i++) // Row\n            {\n                if(matrix[i][j] == 1)\n                    matrix[i][j] += matrix[i-1][j];\n            }\n        }\n\n        for(int i = 0; i < n; i++) // Row\n        {\n            // Arrange the row in sorted and decreasing order\n            sort(matrix[i].begin(),matrix[i].end(),greater<int>());\n            for(int j = 0; j < m; j++) // Col\n            {\n               int length = matrix[i][j];\n               int breadth = j + 1;\n               ans = max( ans, length * breadth);\n            }\n        }\n        return ans;\n    }\n};\n```
['Array', 'Greedy', 'C', 'Sorting', 'Matrix', 'Python', 'C++', 'Java', 'JavaScript']