Skip to content

Commit 469d86c

Browse files
committed
fix bug
1 parent cd90839 commit 469d86c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

search_a_2D_matrix_II/search_a_2D_matrix_II.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ func searchMatrix(matrix [][]int, target int) bool {
99
if matrix[row][col] == target {
1010
return true
1111
}
12-
for row <= len(matrix)-1 && matrix[row][col] < target {
12+
for row <= len(matrix)-1 && col >= 0 && matrix[row][col] < target {
1313
row++
1414
}
15-
for col >= 0 && matrix[row][col] > target {
15+
for row <= len(matrix)-1 && col >= 0 && matrix[row][col] > target {
1616
col--
1717
}
1818
}

0 commit comments

Comments
 (0)