The TransCompilator

Solved LeetCode program · 73 of 1,000

#0073 · Set Matrix Zeroes

Medium Array chunk-02.md

Original English source

The matrix is a list of 1, 1, 1, 1, 0, 1, 1, 1, and 1. The rows is 3. The columns is 3. The lastrow is rows minus 1. The lastcolumn is columns minus 1. The rowmarks is an empty list of whole numbers. The colmarks is an empty list of whole numbers.
For every row from 0 to lastrow.
For every column from 0 to lastcolumn.
If item (row times columns plus column) of matrix is 0, Place row into rowmarks. If item (row times columns plus column) of matrix is 0, Place column into colmarks.

For each row in rowmarks.
For every column from 0 to lastcolumn.
Set item (row times columns plus column) of matrix to 0.

For each column in colmarks.
For every row from 0 to lastrow.
Set item (row times columns plus column) of matrix to 0.

For each value in matrix, display value.

Open in Playground Browse all 1,000 problems

Expected stdout

1
0
1
0
0
0
1
0
1