Spot the Differences
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
1 <= rows, cols <= 10, whererows = len(a)andcols = len(a[0])bhas the same number of rows and columns asa-100 <= a[r][c], b[r][c] <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.