-
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
package com.fishercoder.solutions.fourththousand;
public class _3127 {
public static class Solution1 {
public boolean canMakeSquare(char[][] grid) {
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
if (isPossible(grid, i, j, 'B') || isPossible(grid, i, j, 'W')) {
return true;
}
}
}
return false;
}
private boolean isPossible(char[][] grid, int startI, int startJ, char color) {
int count = 0;
for (int i = startI; i < startI + 2; i++) {
for (int j = startJ; j < startJ + 2; j++) {
if (grid[i][j] == color) {
count++;
}
}
}
return count >= 3;
}
}
}