classSolution{ funcsetZeroes(_matrix: inout [[Int]]) { var count =0 let r = matrix.count, c = matrix[0].count var arr = [Int].init(repeating: -1, count: r*c) for i in0..< r { for j in0..< c { if matrix[i][j] ==0 { //下标为序号,除以宽度即为行号 //数组值为列号 arr[count] = count % c } count +=1 } } for row in0..< r*c { if arr[row] !=-1 { for i in0..< c { matrix[row/c][i] =0 } for j in0..< r { matrix[j][arr[row]] =0 } } } } }