Skip to content

Commit 3cc8c61

Browse files
authored
[20260123] PGM / LV2 / 가장 큰 정사각형 찾기 / 강신지
1 parent bab0e94 commit 3cc8c61

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```java
2+
class Solution {
3+
public int solution(int[][] board) {
4+
int n = board.length;
5+
int m = board[0].length;
6+
7+
int[][] dp = new int[n][m];
8+
int max = 0;
9+
10+
for (int i = 0; i < n; i++) {
11+
for (int j = 0; j < m; j++) {
12+
if (board[i][j] == 1) {
13+
if (i == 0 || j == 0) {
14+
dp[i][j] = 1;
15+
} else {
16+
dp[i][j] = Math.min(Math.min(dp[i-1][j], dp[i][j-1]),dp[i-1][j-1])+1;
17+
}
18+
max = Math.max(max, dp[i][j]);
19+
}
20+
}
21+
}
22+
23+
return max * max;
24+
}
25+
}
26+
```

0 commit comments

Comments
 (0)