Skip to content

Commit e23e2b7

Browse files
authored
and his angels were cast out with him
And the great dragon was cast out, that old serpent, called the Devil, and Satan, which deceiveth the whole world: he was cast out into the earth, and his angels were cast out with him. (Revelation 12:9)
1 parent 3d0c235 commit e23e2b7

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
//And the great dragon was cast out, that old serpent, called the Devil, and Satan,
3+
//which deceiveth the whole world: he was cast out into the earth, and his angels were cast out with him. (Revelation 12:9)
4+
5+
package com.javarush.task.task39.task3912;
6+
7+
/*
8+
Максимальная площадь
9+
*/
10+
11+
public class Solution {
12+
public static void main(String[] args) {
13+
14+
}
15+
16+
public static int maxSquare(int[][] matrix) {
17+
int m = matrix.length;
18+
int n = matrix[0].length;
19+
int side = 0;
20+
for (int i = 0; i < m; i++) {
21+
for (int j = 0; j < n; j++) {
22+
if (i * j == 0)
23+
continue;
24+
if (matrix[i][j] == 1)
25+
matrix[i][j] = Math.min(matrix[i][j - 1], Math.min(matrix[i - 1][j], matrix[i - 1][j - 1])) + 1;
26+
27+
if (matrix[i][j] > side)
28+
side = matrix[i][j];
29+
}
30+
}
31+
32+
return side * side;
33+
}
34+
}
35+
36+
/*
37+
Максимальная площадь
38+
39+
Реализуй метод int maxSquare(int[][] matrix), возвращающий площадь самого большого квадрата состоящего из единиц в двумерном массиве matrix.
40+
41+
Массив matrix заполнен только нулями и единицами.
42+
43+
44+
45+
46+
47+
Требования:
48+
49+
1. Метод maxSquare должен быть реализован в соответствии с условием задачи.
50+
51+
2. Метод maxSquare должен эффективно работать с большими массивами.
52+
53+
3. Метод maxSquare должен быть публичным.
54+
55+
4. Метод maxSquare должен возвращать число типа int.
56+
57+
5. Метод maxSquare должен быть статическим.
58+
*/

0 commit comments

Comments
 (0)