Leetcode Maximal Rectangle
来源:互联网 发布:粒子群算法原理 编辑:程序博客网 时间:2024/05/21 13:50
class Solution {public: int maximalRectangle(vector<vector<char> > &matrix) { // Start typing your C/C++ solution below // DO NOT write int main() function int ro = matrix.size(); int res = 0; if(ro<=0)return res; int c = matrix[0].size(); if(c==0)return res; vector<int>f(c,0); vector<int>l(c,-1); vector<int>r(c,c); int i,j,k; for(i=0;i<ro;i++) { int leftMost = -1; for(j=0;j<c;j++) { l[j] = max(leftMost,l[j]); if(matrix[i][j]=='1') { f[j]++; } else { l[j]=-1; f[j]=0; leftMost=j; } } int rightMost=c; for(j=c-1;j>=0;j--) { r[j] = min(rightMost,r[j]); if(matrix[i][j]=='0') { rightMost = j; r[j] = c; } res = max(res,f[j]*(r[j] - l[j]-1)); } } return res; }};
- 【LeetCode】Maximal Rectangle && Maximal Square
- Leetcode:Maximal Square & Maximal Rectangle
- LeetCode: Maximal Rectangle
- LeetCode Maximal Rectangle
- LeetCode: Maximal Rectangle
- [LeetCode] Maximal Rectangle
- [leetcode] Maximal Rectangle
- [LeetCode]Maximal Rectangle
- [leetcode]Maximal Rectangle
- LeetCode-Maximal Rectangle
- [leetcode] Maximal Rectangle
- Leetcode Maximal Rectangle
- [LeetCode] Maximal Rectangle
- leetcode Maximal Rectangle
- LeetCode Maximal Rectangle
- LeetCode | Maximal Rectangle
- [LeetCode] Maximal Rectangle
- [Leetcode] Maximal Rectangle (Java)
- 内部类
- POJ1151(线段树+扫描线求矩形面积并)
- Requisition auto creat PO
- c语言 指针
- AnchorPoint和Position
- Leetcode Maximal Rectangle
- Linux 利用ssh传输 上传下载 文件
- 2013计算机视觉代码合集二
- Qt之std::string与QString之间的转换
- nandflash读写
- 求字符串中连续出现次数最多的子串
- Radar nyist287
- ubuntu crontab设置定时命令
- 关于fgetc