Skip to content

Commit

Permalink
Create rotate-img.py
Browse files Browse the repository at this point in the history
Beats 98.7% of solutions in runtime. Uses excess memory as a temp for swapping. Better solution for non inplace but still very fast.
  • Loading branch information
gabedonnan authored Jan 15, 2023
1 parent aa2b383 commit 30fd48a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rotate-img.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
x = [[matrix[-(j+1)][i] for j in range(len(row))] for i,row in enumerate(matrix)]
for i,m in enumerate(x):
for j,n in enumerate(m):
matrix[i][j] = n

0 comments on commit 30fd48a

Please sign in to comment.