Python math way


  • 0
    _
        n = len(matrix)
        if n < 2:
            return 
        for i in range(n):
            for j in range(i, n):
                matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
                
        for i in range(n):
            for j in range(n/2):
                matrix[i][j], matrix[i][n-j-1] = matrix[i][n-j-1], matrix[i][j]

Log in to reply
 

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