Skip to content

Latest commit

 

History

History
19 lines (17 loc) · 557 Bytes

048.md

File metadata and controls

19 lines (17 loc) · 557 Bytes

48. Rotate Image

Solution 1 (O(mn))

class Solution(object):
    def rotate(self, matrix):
        """
        :type matrix: List[List[int]]
        :rtype: void Do not return anything, modify matrix in-place instead.
        """
        m = len(matrix)
        n = len(matrix[0])
        for i in range(m // 2):
            matrix[i], matrix[m - 1 - i] = matrix[m - 1 - i], matrix[i]
        for i in range(1, m):
            for j in range(i):
                matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]