current position:Home>About the rotation matrix on leetcode!

About the rotation matrix on leetcode!

2022-02-03 00:55:34 CSDN Q & A

I can't figure out what went wrong
class Solution:    def rotate(self, matrix: List[List[int]]) -> None:        """        Do not return anything, modify matrix in-place instead.        """        j=i=0        matrix_1=matrix        n=len(matrix)        while i<n:            while j<n:                (matrix_1[i])[j]=(matrix[j])[n-i-1]                j+=1            i+=1                matrix=matrix_1

![img]( Operation results and error reporting contents https://img-mid.csdnimg.cn/release/static/image/mid/ask/285663747936172.png "#left")

My solution ideas and tried methods
What I want to achieve



Refer to the answer 1:

I uploaded the wrong code I'll upload it again

class Solution:    def rotate(self, matrix: List[List[int]]) -> None:        """ Do not return anything, modify matrix in-place instead. """        j=i=0        matrix_1=matrix        n=len(matrix)        while i<n:            while j<n:                (matrix_1[i])[j]=(matrix[n-1-j])[i]                j+=1            j=0            i+=1                matrix=matrix_1



Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030055322737.html

Random recommended