grid of size n×n, say the pixels of a picture. Turn it 90° clockwise.
Return the turned table. Try to do the turn in place: change grid itself without allocating a second table.grid=[[1, 2], [3, 4]] → [[3, 1], [4, 2]]
After a clockwise turn the left column, read bottom to top, becomes the top row: [[3, 1], [4, 2]].
grid=[[0, -1, 2], [3, 4, 5], [6, 7, 8]] → [[6, 3, 0], [7, 4, -1], [8, 5, 2]]
The result is [[6, 3, 0], [7, 4, -1], [8, 5, 2]]; the center cell 4 stays put.
grid=[[7]] → [[7]]
A 1×1 table does not change when turned.
grid has n rows of n numbers eachgrid=[[1, 2], [3, 4]]
[[3, 1], [4, 2]]
Run checks the first 3 tests in your browser. Submit checks all 35 tests on the server, hidden ones included.