专栏名称: 每日一道算法题
学习算法是一种信仰,每天都需要坚持!
目录
相关文章推荐
算法爱好者  ·  DeepSeek 下棋靠忽悠赢了 ... ·  1小时前  
算法爱好者  ·  为 DeepSeek 辟谣:五大误解与真相解读 ·  2 天前  
九章算法  ·  最后一天!九章消费券免费抢! ·  5 天前  
九章算法  ·  谷歌/亚麻的BQ题库,附上标准答案! ·  3 天前  
51好读  ›  专栏  ›  每日一道算法题

363. Max Sum of Rectangle No Larger Than K

每日一道算法题  · 公众号  · 算法  · 2017-08-06 09:01

正文


Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k.


Example:

Given matrix = [

[1, 0, 1],

[0, -2, 3]

]

k = 2

The answer is 2. Because the sum of rectangle [[0, 1], [-2, 3]] is 2 and 2 is the max number no larger than k (k = 2).


Note:

The rectangle inside the matrix must have an area > 0.

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


提示 提交代码后 需要用简洁的语言解释一下代码思路 ~ 谢谢


历史题目和总结见公众号「每日一道算法题」


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









请到「今天看啥」查看全文