Write a function that takes a 2-Dimensional array of integers and returns a copy of that array rotated 90 degrees (clockwise). Are you able to do this in place? Note that these 2 Dimensional arrays will be squares, (N x N) with the same numbers of rows and columns.
let picture1 = [
[1, 1, 1, 1],
[0, 1, 1, 1],
[0, 1, 1, 1],
[0, 0, 0, 1],
]
let picture2 = [
[1, 1, 1, 1],
[1, 0, 1, 1],
[0, 1, 0, 1],
[1, 1, 0, 1],
]
rotate(picture1); // should return
/* [
[0, 0, 0, 1],
[0, 1, 1, 1],
[0, 1, 1, 1],
[1, 1, 1, 1],
] */
rotate(picture2); // should return
/* [
[1, 0, 1, 1],
[1, 1, 0, 1],
[0, 0, 1, 1],
[1, 1, 1, 1],
] */
Before you get started, write some examples of your own of different sizes of 2 Dimensional arrays. Is there any pattern when these get rotated?