(int[][] matrix)
| 71 | } |
| 72 | |
| 73 | public static void setZeros(int[][] matrix) { |
| 74 | boolean[] row = new boolean[matrix.length]; |
| 75 | boolean[] column = new boolean[matrix[0].length]; |
| 76 | |
| 77 | // Store the row and column index with value 0 |
| 78 | for (int i = 0; i < matrix.length; i++) { |
| 79 | for (int j = 0; j < matrix[0].length;j++) { |
| 80 | if (matrix[i][j] == 0) { |
| 81 | row[i] = true; |
| 82 | column[j] = true; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // Nullify rows |
| 88 | for (int i = 0; i < row.length; i++) { |
| 89 | if (row[i]) { |
| 90 | nullifyRow(matrix, i); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // Nullify columns |
| 95 | for (int j = 0; j < column.length; j++) { |
| 96 | if (column[j]) { |
| 97 | nullifyColumn(matrix, j); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | public static boolean matricesAreEqual(int[][] m1, int[][] m2) { |
| 103 | if (m1.length != m2.length || m1[0].length != m2[0].length) { |
no test coverage detected