leetcode -- Rotate Image -- trick 가 있 는 걸 봐 야 지.

1068 단어 LeetCode
https://leetcode.com/problems/rotate-image/
리 버스http://www.cnblogs.com/zuoyuan/p/3772978.html
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 range(n):
            for j in range(i+1, n):
                matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
        for i in range(n):
            matrix[i].reverse()

좋은 웹페이지 즐겨찾기