Maximum sum rectangle bounded
Your task
Given an m x n integer matrix and an integer k, find the maximum sum of a rectangular submatrix such that the sum is no larger than k. It is guaranteed that at least one such submatrix exists. Return that maximum sum (which may be negative).
Examples
max_sum_submatrix(matrix: list[list[int]], k: int) -> intExample 1
Input
max_sum_submatrix([[1, 0, 1], [0, -2, 3]], 2)Output
2