leetcode|LeetCode 48. Rotate Image 时间复杂度(O(n))

import copy class Solution: def rotate(self, matrix: [[int]]) -> None: cmatrix = copy.deepcopy(matrix) mlen = len(matrix) for i in range(mlen // 2): curr_len = mlen - i * 2 for j in range(curr_len - 1): ii, jj = i, i + j iii, jjj = i + j,i + curr_len - 1 matrix[iii][jjj] = cmatrix[ii][jj] ii, jj = iii, jjj iii, jjj = i + curr_len - 1,i + curr_len - 1 - j matrix[iii][jjj] = cmatrix[ii][jj] ii, jj = iii, jjj iii, jjj = i + curr_len - 1 - j, i matrix[iii][jjj] = cmatrix[ii][jj] ii, jj = iii, jjj iii, jjj = i, i + j matrix[iii][jjj] = cmatrix[ii][jj]

【leetcode|LeetCode 48. Rotate Image 时间复杂度(O(n))】

    推荐阅读