Skip to content

Instantly share code, notes, and snippets.

@vrat28
Created April 25, 2021 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrat28/0cc284afbc4087e248d7d1f497b1179b to your computer and use it in GitHub Desktop.
Save vrat28/0cc284afbc4087e248d7d1f497b1179b to your computer and use it in GitHub Desktop.
Rotate Image (Python)
lass 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 xrange(n):
for j in xrange(n):
if i < j:
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
for l in matrix:
l.reverse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment