Loading your interview setup
Skip to content
New
Loading
LarpCode 150
medium
· math-geometry
Mock interview
Rotate Image
Given an n x n `matrix`, rotate it 90 degrees clockwise in place and return it.
Examples
in: matrix = [[1,2,3],[4,5,6],[7,8,9]]
out: [[7,4,1],[8,5,2],[9,6,3]]
rotated clockwise
Constraints
1 <= n <= 20
-1000 <= matrix[i][j] <= 1000
Hints
Stuck? Show a hint (2 available)
Python
JavaScript
Java
C++
Go
Run
Submit
target: O(n^2) time
⌘↩ run · ⇧⌘↩ submit
see the solution