标签:直接 div blog 维数 turn 旋转 ret 思路 self
题目描述:把一个二维数组顺时针旋转90度;
class Solution(object):
def rotate(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
n = len(matrix)
m = 0
while m <= n / 2:
k = m
while k < n - 1 - m:
matrix[m][k], matrix[k][n-1-m], matrix[n-1-m][n-1-k], matrix[n-1-k][m] = \
matrix[n-1-k][m], matrix[m][k], matrix[k][n-1-m], matrix[n-1-m][n-1-k]
k += 1
m += 1
Python 解leetcode:48. Rotate Image
标签:直接 div blog 维数 turn 旋转 ret 思路 self
原文地址:http://www.cnblogs.com/qiaojushuang/p/8013001.html