Max Sum of a Sub-Rectangle No Larger Than K (LC 363)

Asked at XPeng · Coding Questions · Difficulty: Hard

Given an integer matrix `matrix` of size `m x n` and an integer `k`, find a **non-empty** sub-rectangle (a contiguous range of rows and a contiguous range of columns) such that the sum of its elements `sum` satisfies:

Loading the problem…