- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_3127.java
28 lines (26 loc) · 878 Bytes
/
_3127.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
packagecom.fishercoder.solutions.fourththousand;
publicclass_3127 {
publicstaticclassSolution1 {
publicbooleancanMakeSquare(char[][] grid) {
for (inti = 0; i < 2; i++) {
for (intj = 0; j < 2; j++) {
if (isPossible(grid, i, j, 'B') || isPossible(grid, i, j, 'W')) {
returntrue;
}
}
}
returnfalse;
}
privatebooleanisPossible(char[][] grid, intstartI, intstartJ, charcolor) {
intcount = 0;
for (inti = startI; i < startI + 2; i++) {
for (intj = startJ; j < startJ + 2; j++) {
if (grid[i][j] == color) {
count++;
}
}
}
returncount >= 3;
}
}
}