class Solution(object):
def rotate(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix inplace instead.
"""
matrix[::] = zip(*matrix[::1])
1 line in Python

38 ms, easy to understand, first transpose, then flip horizontally
class Solution(object): def rotate(self, matrix): n = len(matrix) # transpose for i in range(n): for j in range(i + 1, n): tmp = matrix[i][j] matrix[i][j] = matrix[j][i] matrix[j][i] = tmp # flip horizontally for i in range(n): for j in range(n/2): tmp = matrix[i][j] matrix[i][j] = matrix[i][n  1  j] matrix[i][n  1 j] = tmp

my solution:
def rotate(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix inplace instead. """ length = len(matrix) for i in range(int(length/2)): count = 0 for j in range(i,length1i): matrix[i][j], matrix[i+count][lengthi1], matrix[lengthi1][lengthj1], matrix[lengthj1][i] = \ matrix[lengthj1][i], matrix[i][j], matrix[i+count][lengthi1], matrix[lengthi1][lengthj1] count += 1

@leetcoder07 said in 1 line in Python:
matrix[::] = zip(*matrix[::1])
I wonder if it meets the question. Because it changes list[list,list,...] to list[tuple,tuple,...]

@leetcoder07
it gives this error:
Do not return anything, modify matrix inplace instead.