Day 18 Task:
6. Set Matrix Zeroes: https://leetcode.com/problems/set-matrix-zeroes/
Solutions:
class Solution:
def setZeroes(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
def rowToZero(arr):
for i in range(len(arr)):
arr[i] = 0
def columnElementToZero(arr, x):
for i in range(len(arr)):
arr[i][x] = 0
zloc = []
for i in range(len(matrix)):
for j in range(len(matrix[i])):
if(matrix[i][j] == 0):
zloc.append([i,j])
for i in range(len(zloc)):
columnElementToZero(matrix, zloc[i][1])
for i in range(len(zloc)):
rowToZero(matrix[zloc[i][0]])