Dsa
Matrix
Warm-up
Fill Matrix with Zeros
You are given an m x n matrix of integers. Write a function that modifies the matrix in place to set entire row and column to 0's if an element is 0. The input starts with two integers m and n (the dimensions of the matrix) followed by m lines of space-separated integers representing the matrix. After modifying the matrix, print each row, space-separated.
Example:
Input:
3 3
1 1 1
1 0 1
1 1 1
Output:
1 0 1
0 0 0
1 0 1
Key concepts
matrixmanipulationzero
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now