Re: [闲聊] 每日leetcode

楼主: sixB (6B)   2025-08-22 01:41:14
1504.
我昨天写正方形也是先看到n < 300
直接开3个loop
class Solution {
public:
int numSubmat(vector<vector<int>>& mat) {
int m = mat.size(), n = mat[0].size();
vector<int> cnt(n, 0);
int res = 0;
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
if(mat[i][j] == 0){
cnt[j] = 0;
continue;
}
cnt[j]++;
int bound = cnt[j];
for(int k = j; k >= 0 and bound > 0; k
作者: deatheo (逆十字)   2025-08-22 01:43:00
大师
作者: JIWP (JIWP)   2025-08-22 01:44:00
别卷了
作者: moumoon5566 (廢文果實能力者)   2025-08-22 01:46:00
第9行 代数错了
作者: minisung (糸守町口嚼酱油酿造大师)   2025-08-22 01:54:00
O(mn)解呢
作者: davie11333 (163)   2025-08-22 02:03:00
别卷惹

Links booklink

Contact Us: admin [ a t ] ucptt.com