Rotate Image
Medium
Topics
Given an n x n matrix, rotate it 90 degrees clockwise. LeetCode mutates in place and returns void; here return the rotated matrix.
Example 1
Input: grid = [[1,2,3],[4,5,6],[7,8,9]] Output: [[7,4,1],[8,5,2],[9,6,3]]
Example 2
Input: grid = [[1,2],[3,4]] Output: [[3,1],[4,2]]
Constraints
- 1 <= n <= 20
- -1000 <= matrix[i][j] <= 1000
Run ⌘' · Submit ⌘⏎