Given a multi-dimensional array, loop through each element looking for 0s. When a 0 is found set that entire column and row to 0. The newly updated values don't count toward your search for 0s in the matrix. Here's an example:
//IN [1,2,0] [3,4,5] [6,7,8] //OUT [0,0,0] [3,4,0] [6,7,0]
Comments:
David - 9 years, 4 months ago
reply permalink