My clean Python code


  • 1
    C
     if len(matrix):
                if len(matrix[0]):
                    col = len(matrix[0])
                    row = len(matrix)
                    jbase = 0
                    jh = col
                    for i in range(0, row/2):
                        for j in range(jbase, jh  - 1):
                            temp = matrix[i][j]                
                            matrix[i][j] = matrix[col - 1 - j][i]
                            matrix[col - 1 - j][i] = matrix[col - 1 - i][col - 1 - j]
                            matrix[col - 1 - i][col - 1 - j] = matrix[j][col - 1 - i]
                            matrix[j][col - 1 - i] = temp
        
                        jbase += 1
                        jh -= 1

Log in to reply
 

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