Member-only story

Set Zeros in Matrix (Arrays) (coding interview)β€” Grasp the Pattern! 😎

Ganesh Prasad
5 min readAug 11, 2021

--

Setting zeros in a matrix (Medium)

This is an interesting array-based problem, and it has been asked by Facebook, Microsoft, Amazon, Oracle, Goldmann Sachs and Apple.

In an interview, it is very important to start your solution from brute force and improve. Interviewers know that their asked problem or similar problem is available on the internet and you might have gone through it.

So relax, read every section carefully and try to answer in the same order unless asked differently (for example, πŸ˜„ interviewer might be in a hurry, and they will ask you to give a quick answer).

This problem is part of the 30 days preparation plan for coding interviews.

Table of Contents:

Description

Given a 2D matrix, if any cell contains 0, set 0 to that whole row and column. So if cell (i, j) contains 0, then set ith row and jth column to 0.

Example:
Input: 1 1 1 1
…

--

--

Ganesh Prasad
Ganesh Prasad

Written by Ganesh Prasad

Backend Developer at Appscrip | C++ veteran, πŸ’œ Dart

No responses yet