Given a m x n grid filled with integers, find the submatrix with maximum sum among all submatrices.
Example:
Input: [ [ 1, -9, -10, 1], [-1, 10, 10, 1], [ 0, 9, 9, -9], [-1, -1, -1, -1] ] Output: 38 Explanation: Submatrix [[10, 10], [9, 9]]
Walkthroughs of the solution. Try the steps first, then watch to compare approaches.
Solution #3 · O(n^2 * m)
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check