Created
April 25, 2021 15:08
-
-
Save vrat28/0cc284afbc4087e248d7d1f497b1179b to your computer and use it in GitHub Desktop.
Rotate Image (Python)
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
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