0363. Max Sum of Rectangle No Larger Than K

https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k

Description

Given an m x n matrix matrix and an integer k, return the max sum of a rectangle in the matrix such that its sum is no larger than k.

It is guaranteed that there will be a rectangle with a sum no larger than k.

Example 1:

Example 2:

Constraints:

  • m == matrix.length

  • n == matrix[i].length

  • 1 <= m, n <= 100

  • -100 <= matrix[i][j] <= 100

  • -105 <= k <= 105

Follow up: What if the number of rows is much larger than the number of columns?

ac

Last updated

Was this helpful?