-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path1727.cpp
More file actions
25 lines (23 loc) · 692 Bytes
/
1727.cpp
File metadata and controls
25 lines (23 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Solution {
public:
int largestSubmatrix(vector<vector<int>>& matrix) {
int m = matrix.size();
int n = matrix[0].size();
for (int i = 0; i < n; ++i) {
int cnt = 0;
for (int j = 0; j < m; ++j) {
if (matrix[j][i] == 0) cnt = 0;
matrix[j][i] = cnt + matrix[j][i];
cnt = matrix[j][i];
}
}
int res = 0;
for (int i = 0; i < m; ++i) {
sort(matrix[i].begin(), matrix[i].end(), greater<int>());
for (int j = 0; j < n; ++j) {
res = max(res, matrix[i][j] * (j + 1));
}
}
return res;
}
};