Comprehensible python solution


  • 2
    F
    class Solution(object):
        def rotate(self, matrix):
            """
            :type matrix: List[List[int]]
            :rtype: void Do not return anything, modify matrix in-place instead.
            """
            n = len(matrix)
            for i in xrange(n):
                for j in xrange(n):
                    if i < j:
                        matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
            for l in matrix:
                l.reverse()
    

Log in to reply
 

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