LeetCode-48-Rotate Image 矩阵旋转90

一直搞不明白在Python里怎么快速复制一个矩阵

class Solution(object):
    def rotate(self, matrix):
        """
        :type matrix: List[List[int]]
        :rtype: void Do not return anything, modify matrix in-place instead.
        """
        
        Len=len(matrix)
        if Len==0:return
        copy=[[0 for x in range(Len)]for y in range(Len)]
        for i in range(Len):
            for j in range(Len):
                copy[j][Len-i-1]=matrix[i][j]
        for i in range(Len):
            for j in range(Len):
                matrix[i][j]=copy[i][j]


你可能感兴趣的:(Leetcode)