my python solutions


  • 0
    R
    class Solution(object):
        def rotate(self, matrix):
            n=len(matrix)-1
            left=0
            right=n-1
            while left<=right:
                for j in range(left,right+1):
                    matrix[left][j],matrix[j][n-left],matrix[n-left][n-j],matrix[n-j][left]=\
                    matrix[n-j][left],matrix[left][j],matrix[j][n-left],matrix[n-left][n-j]
                left+=1
                right-=1
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.