求:喷果树红蜘蛛的药名# gardening - 拈花惹草
b*e
1 楼
Given a NxN matrix with 0s and 1s. Now whenever you encounter a 0 make the
corresponding row and column elements 0.
Flip 1 to 0 and 0 remains as they are.
for example
1 0 1 1 0
0 1 1 1 0
1 1 1 1 1
1 0 1 1 1
1 1 1 1 1
results in
0 0 0 0 0
0 0 0 0 0
0 0 1 1 0
0 0 0 0 0
0 0 1 1 0
my solution is define a function remove1(x1,y1,x2,y2)
(x1,y1) is the matrix start point, and (x2,y2) is the end point
if(i,j) == 1, we need remove all 1 from i row and j column
so we divide into four small matrix
resrucive
corresponding row and column elements 0.
Flip 1 to 0 and 0 remains as they are.
for example
1 0 1 1 0
0 1 1 1 0
1 1 1 1 1
1 0 1 1 1
1 1 1 1 1
results in
0 0 0 0 0
0 0 0 0 0
0 0 1 1 0
0 0 0 0 0
0 0 1 1 0
my solution is define a function remove1(x1,y1,x2,y2)
(x1,y1) is the matrix start point, and (x2,y2) is the end point
if(i,j) == 1, we need remove all 1 from i row and j column
so we divide into four small matrix
resrucive