48. Rotate Image
704 ワード
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
h = len(matrix[0])
# transpose
for i in range(h):
for j in range(i, h):
matrix[j][i], matrix[i][j] = matrix[i][j], matrix[j][i]
for i in range(h):
matrix[i].reverse()
Transpose->リバース実行Runtime: 32 ms, faster than 81.59% of Python3 online submissions for Rotate Image.
Memory Usage: 14.3 MB, less than 17.96% of Python3 online submissions for Rotate Image.
Reference
この問題について(48. Rotate Image), 我々は、より多くの情報をここで見つけました https://velog.io/@jwade/48.-Rotate-Imageテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol