class Solution:
    def rotate(self, matrix):
        """
        Time: N^2
        Space: 1
        :type matrix: List[List[int]]
        :rtype: void Do not return anything, modify matrix in-place instead.
        """
        for i in range(len(matrix)):
            for j in range(i + 1, len(matrix)):
                matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]

        for i in range(len(matrix)):
            for j in range(len(matrix) // 2):
                matrix[i][j], matrix[i][len(matrix) - 1 - j] = matrix[i][len(matrix) - 1 - j], matrix[i][j]


if __name__ == '__main__':
    sol = Solution()
    ip = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
    sol.rotate(ip)
    print(ip)
