Search
⌘K

Leetcode 363. Max Sum of Rectangle No Larger Than K

Find the maximum-sum subrectangle in an m×n matrix whose sum is no larger than k. The core challenge is reducing the 2D problem to many 1D "max subarray ≤ k" problems by fixing two boundaries and using prefix sums with an ordered set to quickly find the best subarray; iterate over the smaller dimension if rows ≫ columns.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.