(int[][] matrix)
| 19 | } |
| 20 | |
| 21 | public static Subsquare findSquare(int[][] matrix){ |
| 22 | assert(matrix.length > 0); |
| 23 | for (int row = 0; row < matrix.length; row++){ |
| 24 | assert(matrix[row].length == matrix.length); |
| 25 | } |
| 26 | |
| 27 | SquareCell[][] processed = processSquare(matrix); |
| 28 | |
| 29 | int N = matrix.length; |
| 30 | |
| 31 | for (int i = N; i >= 1; i--) { |
| 32 | Subsquare square = findSquareWithSize(processed, i); |
| 33 | if (square != null) { |
| 34 | return square; |
| 35 | } |
| 36 | } |
| 37 | return null; |
| 38 | } |
| 39 | |
| 40 | private static boolean isSquare(SquareCell[][] matrix, int row, int col, int size) { |
| 41 | SquareCell topLeft = matrix[row][col]; |
no test coverage detected