Deviopath › JavaScript

Rotate a Matrix

Medium · Arrays

Write a function rotateMatrix that returns a new matrix rotated 90 degrees clockwise. Do not change the input.

The matrix can be rectangular: a matrix with m rows and n columns becomes one with n rows and m columns. For an empty matrix return [].

Next: Min Stack