Skip to content

Commit 1156308

Browse files
authored
Update max-sum-of-sub-matrix-no-larger-than-k.cpp
1 parent bab79b7 commit 1156308

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

C++/max-sum-of-sub-matrix-no-larger-than-k.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ class Solution {
2222
// Find the max subarray no more than K.
2323
set<int> accu_sum_set;
2424
accu_sum_set.emplace(0);
25-
int accu_sum = 0, curr_max = numeric_limits<int>::min();
25+
int accu_sum = 0;
2626
for (int sum : sums) {
2727
accu_sum += sum;
2828
auto it = accu_sum_set.lower_bound(accu_sum - k);
2929
if (it != accu_sum_set.end()) {
30-
curr_max = max(curr_max, accu_sum - *it);
30+
result = max(result, accu_sum - *it);
3131
}
3232
accu_sum_set.emplace(accu_sum);
3333
}
34-
result = max(result, curr_max);
3534
}
3635
}
3736

0 commit comments

Comments
 (0)