Reset Matrix Problem Statement

Given a 2D array ARR with 'N' rows and 'M' columns, where each element is either 0 or 1, your task is to transform this matrix into a 'Good' matrix. A 'Good' matrix is one in which for every 0 found in the matrix, all elements in its row and column are set to 0.

Example:

Input:
ARR = [[1, 0, 1], [1, 1, 1], [1, 1, 1]]
Output:
[[0, 0, 0], [1, 0, 1], [1, 0, 1]]
Explanation:

Since ARR[0][1] is 0, all elements in the 0-th row and 1-th column are set to 0.

Constraints:

  • 1 ≤ T ≤ 20
  • 1 ≤ N ≤ 300
  • 1 ≤ M ≤ 300
  • ARR[i][j] can only be 0 or 1

Note: No need to print the matrix; update the input matrix as per the requirements.

AnswerBot
4mo

Transform a 2D array into a 'Good' matrix by setting rows and columns to 0 if a 0 is found.

  • Iterate through the matrix to find 0s

  • For each 0 found, set all elements in its row and column to 0

  • Update the ...read more

Help your peers!
Select
Add answer anonymously...

Infosys System Engineer Specialist interview questions & answers

A System Engineer Specialist was asked Q. What is thrashing in an Operating System?
A System Engineer Specialist was asked Q. What are ACID properties?
A System Engineer Specialist was asked Q. What are NoSQL databases?

Popular interview questions of System Engineer Specialist

A System Engineer Specialist was asked Q1. What is thrashing in an Operating System?
A System Engineer Specialist was asked Q2. What are ACID properties?
A System Engineer Specialist was asked Q3. What are NoSQL databases?
Infosys System Engineer Specialist Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits