grid of digits from 0 to 9. In one operation you may replace the number in any cell with any other non-negative number.
Make the table striped:
- every cell equals the cell below it (if there is one), so each column holds a single number;
- every cell differs from the cell to its right (if there is one), so neighbouring columns differ.
Return the fewest operations needed.grid=[[3, 3], [3, 5]] → 1
The first column is all 3s already. The second must be uniform and not 3, so repaint its top 3 into 5.
grid=[[7], [2], [7]] → 1
A single column: keep the 7s and change the 2.
grid=[[4, 4, 4]] → 1
Neighbouring columns must differ, so the middle 4 becomes any other digit.
grid=[[3, 3], [3, 5]]
1
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.