FunctionRacerProblemsRace

Spot the Differences

BeginnerGridsPython, JavaScript, TypeScript, Java, C++

a and b are two grids of integers with the same shape, each given as a list of rows (the outer list holds the rows, top row first). Return the position [row, col] of every cell where the two grids hold different values, listed in reading order: row by row from the top, and from left to right within a row. Return [] if the grids are identical. Neither grid may be changed.

Example 1

a [[1,2,3],[4,5,6]]
b [[1,0,3],[4,5,7]]
returns [[0,1],[1,2]]

The grids differ at row 0, column 1 (2 against 0) and at row 1, column 2 (6 against 7).

Example 2

a [[7,7],[7,7]]
b [[7,7],[7,7]]
returns []

Every cell matches, so there is nothing to report.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Grids problems