Created
June 5, 2020 04:04
-
-
Save blacksheep557/967028715d3e5d9df571177c989112bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rotateImage(imageMatrix = [[]]) { | |
| //transpose the matrix | |
| for (let row = 0; row < imageMatrix.length; row++) { | |
| for (let col = row + 1; col < imageMatrix[0].length; col++) { | |
| let temp = imageMatrix[row][col]; | |
| imageMatrix[row][col] = imageMatrix[col][row]; | |
| imageMatrix[col][row] = temp; | |
| } | |
| } | |
| // return each row reversed | |
| return imageMatrix.map((row) => row.reverse()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment