Largest Rectangle Sum Under a Limit

Asked at XPeng · Coding Questions · Difficulty: Hard

Given a grid of integers and a limit `k`, find the sub-rectangle whose elements add up to the largest value that is still no greater than `k`. A sub-rectangle is a contiguous block of rows crossed with a contiguous block of columns, and it must contain at least one cell.

Loading the problem…