给定一个 n × n 的二维矩阵表示一个图像。
将图像顺时针旋转 90 度。
说明:
你必须在原地旋转图像,这意味着你需要直接修改输入的二维矩阵。请不要使用另一个矩阵来旋转图像。
class Solution {
func rotate(_ matrix: inout [[Int]]) {
let temp = matrix
let len = matrix.count
for i in 0..<len {
for j in 0..<len {
matrix[j][len - 1 - i] = temp[i][j]
}
}
}
}