FunctionRacerProblemsRace

Quarter Turn

EasyGridsPython, JavaScript, TypeScript, Java, C++

Return a new grid that is grid turned a quarter turn clockwise (90 degrees). A grid with R rows and C columns becomes a grid with C rows and R columns. The first column of grid, read from bottom to top, becomes the first row of the answer; the second column becomes the second row, and so on. Do not change grid itself.

Example 1

grid [[1,2,3],[4,5,6]]
returns [[4,1],[5,2],[6,3]]

The first column 1, 4 read bottom to top gives the first row 4, 1; the other columns follow.

Example 2

grid [[1,2],[3,4]]
returns [[3,1],[4,2]]

The left column 1, 3 becomes the top row 3, 1.

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