https://leetcode.com/problems/rotate-image/description/
沿着副对角反转一次. 在沿着水平线翻转一次即可
class Solution {
func rotate(_ matrix: inout [[Int]]) {
let n = matrix.count
for i in 0 ..< n {
for j in 0 ..< (n - i) {
let temp = matrix[i][j]
matrix[i][j] = matrix[n - 1 - j][n - 1 - i]
matrix[n - 1 - j][n - 1 - i] = temp
}
}
for i in 0 ..< n / 2 {
for j in 0 ..< n {
let temp = matrix[i][j]
matrix[i][j] = matrix[n - 1 - i][j]
matrix[n - 1 - i][j] = temp
}
}
}
}