| 38 | } |
| 39 | |
| 40 | private static boolean isSquare(SquareCell[][] matrix, int row, int col, int size) { |
| 41 | SquareCell topLeft = matrix[row][col]; |
| 42 | SquareCell topRight = matrix[row][col + size - 1]; |
| 43 | SquareCell bottomRight = matrix[row + size - 1][col]; |
| 44 | if (topLeft.zerosRight < size) { // Check top edge |
| 45 | return false; |
| 46 | } |
| 47 | if (topLeft.zerosBelow < size) { // Check left edge |
| 48 | return false; |
| 49 | } |
| 50 | if (topRight.zerosBelow < size) { // Check right edge |
| 51 | return false; |
| 52 | } |
| 53 | if (bottomRight.zerosRight < size) { // Check bottom edge |
| 54 | return false; |
| 55 | } |
| 56 | return true; |
| 57 | } |
| 58 | |
| 59 | public static SquareCell[][] processSquare(int[][] matrix) { |
| 60 | SquareCell[][] processed = new SquareCell[matrix.length][matrix.length]; |