The TransCompilator

Solved LeetCode program · 913 of 1,000

#1267 · Count Servers that Communicate

Medium Array chunk-19.md

Original English source

The grid is a list of 1, 0, 1, and 1. The rows is 2, while the columns is 2. The rowtotals is a list of 2 zeros. The coltotals is a list of 2 zeros.
For every row from 0 to 1.
For every column from 0 to 1.
If item (row times columns plus column) of grid is 1, set item row of rowtotals to item row of rowtotals plus 1, set item column of coltotals to item column of coltotals plus 1.

The linked is 0.
For every row from 0 to 1.
For every column from 0 to 1.
If item (row times columns plus column) of grid is 1 and item row of rowtotals is more than 1, add 1 to linked. If item (row times columns plus column) of grid is 1 and item row of rowtotals is 1 and item column of coltotals is more than 1, add 1 to linked.

Show linked.

Open in Playground Browse all 1,000 problems

Expected stdout

3