Set Matrix Zeroes

Hard · rating 1750 · Matrix

The first line has r and c. The next r lines each have c integers. If a cell is 0, set its entire row and column to 0. Print the resulting matrix, one row per line.

Constraints: 1 ≤ r, c ≤ 500

Related problems

Open Set Matrix Zeroes in Code Arena →