 All Problems
Set Matrix Zeroes
medium
arrays
matrix
amazon
microsoft
google
facebook

Given an m × n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.

Example:

Input:
3 3
1 1 1
1 0 1
1 1 1

Output:
1 0 1
0 0 0
1 0 1

Input format: Line 1 = m n. Next m lines = matrix rows.

Output format: m lines of the modified matrix.

Run to check your code against the sample cases, or submit to run every case