Rotate Matrix
We'll learn how to work with a matrix in JavaScript and how to efficiently manipulate it. We'll cover a couple of clever tricks that can make our lives a lot easier by allowing us to reuse code.
Rotate Matrix
⬇️
Instructions
A matrix in JavaScript can be represented as an array of arrays. For example, here is a 3 x 3 matrix:
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
Write a function that takes a matrix as input and returns a new matrix. This new matrix should represent the original matrix rotated 90 degrees clockwise. The original matrix should be unchanged. This function should work for both square and rectangular matrixes.
Input: Array of Arrays of Numbers
Output: Array of Arrays of Numbers
Example
When given the ...
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.