Rotate Image

You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees clockwise in-place, meaning you have to modify the input 2D matrix directly without allocating another 2D matrix for the rotation.

Constraints

  • n == matrix.length == matrix[i].length
  • 1 <= n <= 20
  • -1000 <= matrix[i][j] <= 1000
Saving… · 2 lines
class Solution:
def rotateImage(self, matrix) -> None:
Console

Click Run to execute sample tests.