Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8df8584

Browse files
committed
dp bottom up lc 221 maximal square java
1 parentb364705 commit8df8584

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎java/0221-maximal-square.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
classSolution {
2+
// dp bottom up
3+
publicintmaximalSquare(char[][]matrix) {
4+
int[][]dp =newint[matrix.length +1][matrix[0].length +1];
5+
intmaxLen =0;
6+
for (introw =matrix.length -1;row >=0;row--) {
7+
for (intcol =matrix[0].length -1;col >=0;col--) {
8+
if (matrix[row][col] =='1') {
9+
dp[row][col] =1 +Math.min(Math.min(dp[row +1][col],dp[row][col +1]),dp[row +1][col +1]);
10+
maxLen =Math.max(maxLen,dp[row][col]);
11+
}
12+
}
13+
}
14+
15+
returnmaxLen *maxLen;
16+
}
17+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp