代码:
- class Solution {
- public int maximalSquare(char[][] matrix) {
- int m = matrix.length;
- int n = matrix[0].length;
- int[][]area = new int[m][n];
- area[0][0] = matrix[0][0];
- int max = 0;
- for(int i=0;i
- area[i][0] = matrix[i][0]=='1'? 1:0;
- max = Math.max(area[i][0],max);
- }
- for(int j=0;j
- area[0][j] = matrix[0][j]=='1'? 1:0;
- max = Math.max(area[0][j],max);
-
- }
- for(int i=1;i
- for(int j=1;j
- if(matrix[i][j]=='0'){
- area[i][j] = 0;
- }else if(area[i-1][j-1]==area[i][j-1]&&area[i-1][j-1]==area[i-1][j]){
- area[i][j] = area[i-1][j-1]+1;
- max = Math.max(area[i][j],max);
- }else{
- area[i][j] = Math.min(Math.min(area[i-1][j-1],area[i-1][j]),area[i][j-1])+1;
- }
- }
- }
- return max*max;
- }
- }
-
相关阅读:
Minio集群搭建
VirtualBox Win7 虚拟机 共享文件夹设置
应用商店优化的好处有哪些?
CMS难题待解?头部企业已领跑前装量产与集成趋势
微信小程序设置 wx.showModal 提示框中 确定和取消按钮的颜色
python项目使用pyinstaller打包
垃圾邮件(短信)分类算法实现 机器学习 深度学习 计算机竞赛
Access denied for user ‘root‘@‘localhost‘ (using password:YES) 解决方案(禅道相关)
Qt MinGW / MSVC
C之fopen/fclose/fread/fwrite/flseek
-
原文地址:https://blog.csdn.net/stacey777/article/details/133918382