Created
August 20, 2020 06:32
-
-
Save iamprayush/3ae43a3b6da2296ba0ffa61334c2af10 to your computer and use it in GitHub Desktop.
Rotate Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def rotate(self, matrix: List[List[int]]) -> None: | |
""" | |
Do not return anything, modify matrix in-place instead. | |
""" | |
n = len(matrix) | |
for i in range(n//2): | |
l, r = i, n - i - 1 | |
x = 0 | |
for j in range(l, r): | |
matrix[l][j], matrix[j][r], matrix[r][r - x], matrix[r - x][l] = ( | |
matrix[r - x][l], matrix[l][j], matrix[j][r], matrix[r][r - x]) | |
x += 1 |
Author
iamprayush
commented
Aug 20, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment