A pixel editor has a "rotate 90 degrees clockwise" button for square canvases. The canvas is grid, an n x n array of pixel values.
Write rotateCanvas(grid) that rotates grid in place: after the call, grid itself holds the rotated canvas, where the old left column (bottom to top) is the new top row. Don't build a second n x n array.
Input: grid = [[1,2],[3,4]] Output: [[3,1],[4,2]]
The left column, read bottom to top, is 3, 1, which becomes the top row.
Input: grid = [[1,0,0],[1,1,0],[1,1,1]] Output: [[1,1,1],[1,1,0],[1,0,0]]
The staircase that rose to the right now steps down to the right.
1 <= n <= 100-1000 <= grid[r][c] <= 1000Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #78 Rotate the Canvas Clockwise. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.