Problem Overview
The "Rotate Image" problem, commonly associated with LeetCode #48 and tagged Array, Matrix, Math, involves rotating an n x n 2D matrix 90 degrees clockwise in-place without using extra space for another matrix.[1]
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.[9][1]
Example 1:
Input: matrix = [,,][2][3][4][5][6][7][8][1][9]
Output: [,,][3][4][5][6][7][8][1][2][9]
Explanation: After rotating 90 degrees clockwise, the top-left becomes bottom-left, and so on.[1]
Example 2:
Input: matrix = [,,,][4][5][6][7][8][10][2][3][9][1]
Output: [,,,].[5][6][7][8][10][2][3][4][9][1]