Algorithm/Online judge

[LeetCode] Array > Rotate Image

민철킹 2021. 5. 7. 18:10

leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/770/

 

Explore - LeetCode

LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore.

leetcode.com

 


풀이

매우 간단한 정방행렬의 회전이다.

import copy
class Solution:
    def rotate(self, matrix: List[List[int]]) -> None:
        """
        Do not return anything, modify matrix in-place instead.
        """
        N = len(matrix)
        ret = copy.deepcopy(matrix)

        for r in range(N):
            for c in range(N):
                matrix[c][N-1-r] = ret[r][c]
반응형

'Algorithm > Online judge' 카테고리의 다른 글

[백준] 1009번 > 분산처리  (0) 2021.05.18
[백준] 14503번 > 로봇 청소기  (0) 2021.05.13
[LeetCode] Array > Two Sum  (0) 2021.05.07
[LeetCode] Array > Move Zeroes  (0) 2021.05.07
[LeetCode] Array > Plus One  (0) 2021.05.07