We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dec8239 commit 3c9e0c2Copy full SHA for 3c9e0c2
src/main/java/io/github/juchanei/leetcodeJava/SetMatrixZeroes.java
@@ -13,8 +13,16 @@ public void setZeroes(int[][] matrix) {
13
}
14
15
private void setZeroes(int x, int y, boolean isZero) {
16
- if (x + 1 < matrix[y].length) setZeroes(x + 1, y, matrix[y][x + 1] == 0);
17
- else if (y + 1 < matrix.length) setZeroes(0, y + 1, matrix[y + 1][0] == 0);
+ boolean found = false;
+ for (int i = y; i < matrix.length && !found; i++) {
18
+ for (int j = i == y ? x + 1 : 0; j < matrix[i].length && !found; j++) {
19
+ if (matrix[i][j] == 0) {
20
+ setZeroes(j, i, true);
21
+
22
+ found = true;
23
+ }
24
25
26
27
if (!isZero) return;
28
0 commit comments