Leetcode 363. Max Sum of Rectangle No Larger Than K
来源:互联网 发布:java class命名 编辑:程序博客网 时间:2024/05/16 14:37
Leetcode 363. Max Sum of Rectangle No Larger Than K
TLE:
public class Solution { public int maxSumSubmatrix(int[][] matrix, int k) { int m = matrix.length; //rows int n = matrix[0].length; //columns int max = Integer.MIN_VALUE; for(int h=0;h<m;h++){ for(int l=0;l<n;l++){ for(int i=0;i<m;i++){ if(i+h>=m) break; for(int j=0;j<n;j++){ if(j+l>=n) break; int sum = 0; for(int g=0;g<=h;g++){ for(int f=0;f<=l;f++){ sum += matrix[i+g][j+f]; } } if(sum > k) continue; if(sum==k) return k; if(sum<k&&sum>max){ max = sum; } } } } } return max; }}
0 0
- [leetcode] 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
- leetcode-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
- [leetcode]363. Max Sum of Rectangle No Larger Than K
- leetcode 363. Max Sum of Rectangle No Larger Than K
- Leetcode Max Sum of Rectangle No Larger Than K
- [LeetCode]Max Sum of Rectangle No Larger Than K
- leetcode(363):Max Sum of Rectangle No Larger Than K
- [LeetCode] Max Sum of Rectangle No Larger Than K
- 【Leetcode】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[hard]
- 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
- Linux守护进程
- 带分数(dfs)
- centos6.5 lamp+gogs环境搭建
- sdutacm-最长上升子序列
- C++ queue
- Leetcode 363. Max Sum of Rectangle No Larger Than K
- Linux系统smbclient命令的使用方法(RaspberryPi)
- HTTP协议响应(详解)
- python 中的深拷贝和浅拷贝
- 0001_20170226_【我是菜鸟】_【Java】_Java Character类
- 程序员必读书籍及导读指南
- 类和继承
- Spring HibernateTemplate详解
- usaco2.3 prefix trie树 + dp