【记一道有意思的算法题Rotate Image(旋转图像)】教程文章相关的互联网学习教程文章

记一道有意思的算法题Rotate Image(旋转图像)【代码】

题出自https://leetcode.com/problems/rotate-image/ 内容为: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度顺时针旋转,而且不能使用额外的存储空间。最初拿到这道题想到的就是找出每个坐标的旋转规律。假设我们是2*2的矩阵:a b c d进行旋转后,那么就变成了:c a ...