Skip to content
New
Loading problem
Rotate Image · medium math geometry interview problem · Larpy
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.
Figure
row · column
0
1
2
0
1
2
1
2
3
4
5
6
7
8
9
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
More math-geometry problems
Happy Number
easy
Plus One
easy
Multiply Strings
medium
Trailing Zeros of a Factorial
medium
Spiral Matrix
medium
Set Matrix Zeroes
medium