添加新题目

This commit is contained in:
2025-08-23 23:09:54 +08:00
parent 62034548cc
commit 70fe6d292c
8 changed files with 260 additions and 2 deletions

View File

@@ -1,9 +1,27 @@
package main
func main() {
setZeroes([][]int{{0, 1, 2, 0}, {3, 4, 5, 2}, {1, 3, 1, 5}})
}
func setZeroes(matrix [][]int) {
col := make([]bool, len(matrix[0]))
row := make([]bool, len(matrix))
for i := range matrix {
for j := range matrix[i] {
if matrix[i][j] == 0 {
col[j] = true
row[i] = true
}
}
}
//fmt.Println("col", col)
//fmt.Println("row", row)
for i := range matrix {
for j := range matrix[i] {
if row[i] || col[j] {
matrix[i][j] = 0
}
}
}
}