You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
描述
给出一个 n*n
的整数型数组,要求将其顺时针旋转 90°,要求不能使用额外数组辅助
分析
将一张纸上下翻转,然后按照对角线翻转,即相当于这张纸旋转 90°
代码
1 | public class Solution { |