leetcode 221. Maximal Square
来源:互联网 发布:5s蜂窝移动数据设置 编辑:程序博客网 时间:2024/06/04 20:06
leetcode 221. Maximal Square
今天晏老师讲依赖论文,确实我有这个毛病,做题也比较依赖答案,其实重要的不是答案,而是解题的思路,这世上没有标准答案,所谓的标准答案都是多种可能实现的极致,它不是先验存在的,而是被创造出来的。
比如这题,如此简单的题,思路很容易有。
师兄说教育是教人自信,有道理。
public class Solution { public int maximalSquare(char[][] a) { int m = a.length; if(m==0) return 0; int n = a[0].length; int min = m<n?m:n; int ans = 0; for(int k=0;k<min;k++){ boolean tk = false; for(int i=0;i+k<m;i++){ for(int j=0;j+k<n;j++){ boolean tij = true; // calculate if for(int ti=0;ti<=k;ti++){ for(int tj=0;tj<=k;tj++){ if(a[i+ti][j+tj]=='0') { tij = false; break; } } if(!tij) break; } if(tij){ tk=true; ans = (k+1)*(k+1); break; } } if(tk) break; } if(!tk) break; } return ans; }}
阅读全文
0 0
- [leetcode] 221.Maximal Square
- 【leetcode】221. Maximal Square
- [LeetCode]221. Maximal Square
- leetcode 221. Maximal Square
- 221. Maximal Square LeetCode
- LeetCode 221. Maximal Square
- LeetCode *** 221. Maximal Square
- LeetCode-221.Maximal Square
- leetcode.221. Maximal Square
- Leetcode 221. Maximal Square
- [leetcode]221. Maximal Square
- [LeetCode]--221. Maximal Square
- leetcode 221. Maximal Square
- Leetcode 221. Maximal Square
- Leetcode 221. Maximal Square
- [LeetCode]221. Maximal Square
- 【Leetcode】221. Maximal Square
- [leetcode]221. Maximal Square
- Linux下搭建FTP服务
- 设计模式(十三):迭代器模式
- ICP算法
- CAS(7)-建立使用Cas进行单点登录的应用
- [转]Reactor模式,或者叫反应器模式
- leetcode 221. Maximal Square
- CAS(8)-单点登出
- windows安装redis扩展
- bzoj 1283: 序列 费用流
- java基本知识
- Struts2学习总结(三):Action与ActionSupport
- CAS(9)-通过Proxy访问其它Cas应用
- hihoCoder太阁最新面经算法竞赛题解(4)
- PL/SQL Developer 导入导出数据库