Set Matrix Zeroes Problem

Set Matrix Zeroes Problem — ExecCode Medium DSA Practice

Solve the Set Matrix Zeroes problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given an m×n integer matrix, if an element is 0, set its entire row and column to 0s. Do it in place. For Set Matrix Zeroes, focus on the exact input variables, return only the requested value, and preserve the required time complexity for the intended pattern.

Examples

Input matrix = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]; Output [[1, 0, 1], [0, 0, 0], [1, 0, 1]]

Constraints

1 ≤ m, n ≤ 200 -2^31 ≤ matrix[i][j] ≤ 2^31 - 1

Practice Set Matrix Zeroes free on ExecCode. Browse DSA problems, topic map, and placement guides.