-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path48.py
More file actions
23 lines (17 loc) · 663 Bytes
/
Copy path48.py
File metadata and controls
23 lines (17 loc) · 663 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Solution(object):
def rotate(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: None Do not return anything, modify matrix in-place instead.
"""
l = len(matrix[0])
for i in range(l):
for j in range(l-i):
matrix[i][j], matrix[l-j-1][l-i-1]=matrix[l-j-1][l-i-1], matrix[i][j]
for i in range(l/2):
for j in range(l):
matrix[i][j], matrix[l-i-1][j] = matrix[l-i-1][j], matrix[i][j]
return matrix
if __name__ == '__main__':
solution = Solution()
print solution.rotate([[5,1,9,11],[2,4,8,10],[13,3,6,7],[15,14,12,16]])