Set Matrix Zeroes

Medium
ArrayMatrixHash TableAmazonMicrosoft
Given an m x n matrix, if an element is 0 set its entire row and column to 0. Print the resulting matrix. Input format: - First line: m n - Next m lines: n integers each Print the updated matrix, one row per line.

Constraints

1 <= m, n <= 1000
1 <= m * n <= 2 * 10^5
-10^9 <= matrix[i][j] <= 10^9

Sample tests

Sample 1

Sample 2

Sign in to submit