An avatar editor has a "rotate right" button. The avatar is a square n × n grid of pixel values. Write rotateClockwise(grid), which rotates the grid 90° clockwise in place (modifying grid itself) and returns it.
const grid = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
];
rotateClockwise(grid);
// grid is now
// [
// [7, 4, 1],
// [8, 5, 2],
// [9, 6, 3],
// ]
After rotation, the old first column (read bottom to top) becomes the new first row.
0 ≤ n ≤ 1000.Spotted a mistake or a rights concern? Report an issue