363. Max Sum of Rectangle No Larger Than K
来源:互联网 发布:中石化邮箱pop端口号 编辑:程序博客网 时间:2024/05/16 17:54
class Solution {public: int maxSumSubmatrix(vector<vector<int>>& matrix, int k) { int row=matrix.size(); if(row==0) return 0; int col=matrix[0].size(); if(col==0) return 0; int ret=INT_MIN; for(int i=0;i<col;i++) { vector<int> sums(row,0); for (int l = i; l < col; l++) { for(int r=0;r<row;r++) { sums[r]+=matrix[r][l]; } set<int> s; s.insert(0); int curmax=INT_MIN; int cursum=0; for(int number:sums) { cursum+=number; set<int>::iterator it=s.upper_bound(cursum-k-1); if(it!=s.end()) curmax=max(curmax,cursum-*it); s.insert(cursum); } ret=max(curmax,ret); } } return ret; }};
1 0
- [leetcode] 363. Max Sum of Rectangle No Larger Than K
- leetcode.363. Max Sum of Rectangle No Larger Than K
- 363. Max Sum of Rectangle No Larger Than K
- [LeetCode]--363. Max Sum of Rectangle No Larger Than K
- leetcode-363. Max Sum of Rectangle No Larger Than K
- 363. Max Sum of Rectangle No Larger Than K[hard]
- 363. Max Sum of Rectangle No Larger Than K
- 363. Max Sum of Rectangle No Larger Than K
- Leetcode 363. Max Sum of Rectangle No Larger Than K
- 【Leetcode】363. Max Sum of Rectangle No Larger Than K
- 363. Max Sum of Rectangle No Larger Than K
- 363. Max Sum of Rectangle No Larger Than K
- [leetcode]363. Max Sum of Rectangle No Larger Than K
- leetcode 363. Max Sum of Rectangle No Larger Than K
- 363. Max Sum of Rectangle No Larger Than K
- Leetcode Max Sum of Rectangle No Larger Than K
- Max Sum of Rectangle No Larger Than K
- [LeetCode]Max Sum of Rectangle No Larger Than K
- 收录文章
- 如何在短时间内高效了解和学习一个技术或者读一本书;
- 解读:从业务的角度看 为什么选择redis而不用memcache
- 判断是否是回文数字
- 读写csv文件的问题
- 363. Max Sum of Rectangle No Larger Than K
- 最新 Eclipse IDE下的Spring框架配置及简单实例
- 关于struts2 API 中InputConfig 内 methodName 和resultName的使用方法
- android 开发技能图谱
- Eclipse中Ctrl+Shift+F不可用
- java使用zookeeper实现的分布式锁示例
- [小技巧]如何获取php一个类中定义的常量
- 【Linux Is Not Unix 】虚拟机下CentOS配置ip三种方法的区别
- 16年,悲痛又收获的一年