m × n table grid diagonal by diagonal, snaking back and forth.
It starts in the top-left corner and moves along the anti-diagonals (all cells of one anti-diagonal share the same row + column). The first anti-diagonal is read going up and to the right, the second going down and to the left, the third up again, and so on until the robot reaches the bottom-right corner.
Return the values in the order the robot reads them.grid=[[5, 1, 9], [2, 8, 4]] → [5, 1, 2, 8, 9, 4]
First 5, then down-left: 1, 2. Then up-right: 8, 9. The last diagonal goes down and holds just one cell, 4.
grid=[[3], [7], [6]] → [3, 7, 6]
With a single column every diagonal is one cell, so the walk simply goes top to bottom.
grid=[[-4, 10]] → [-4, 10]
grid=[[5, 1, 9], [2, 8, 4]]
[5, 1, 2, 8, 9, 4]
Run checks the first 3 tests in your browser. Submit checks all 65 tests on the server, hidden ones included.