Skip to content

Commit c07415b

Browse files
committed
Create 48. Rotate Image.py
1 parent 6ebd3ee commit c07415b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: 48. Rotate Image.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2019/2/27 16:02
3+
# @Author : xulzee
4+
5+
# @File : 48. Rotate Image.py
6+
# @Software: PyCharm
7+
from typing import List
8+
9+
10+
class Solution:
11+
def rotate(self, matrix: List[List[int]]) -> None:
12+
"""
13+
Do not return anything, modify matrix in-place instead.
14+
"""
15+
for i in range(len(matrix)):
16+
for j in range(i + 1, len(matrix[0])):
17+
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
18+
matrix[i] = matrix[i][::-1]
19+
20+
21+
if __name__ == '__main__':
22+
A = [
23+
[1, 2, 3],
24+
[4, 5, 6],
25+
[7, 8, 9]
26+
]
27+
Solution().rotate(A)
28+
print(A)

0 commit comments

Comments
 (0)