```
class Solution(object):
def rotate(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
l = len(matrix)
if l%2 == 0:
g = l//2
else:
g = l//2 + 1
for i in range(g):
for j in range(i,l-1-i):
a = matrix[i][j]
b = matrix[j][l-1-i]
c = matrix[l-1-i][l-1-j]
d = matrix[l-1-j][i]
matrix[i][j] = d
matrix[j][l-1-i] = a
matrix[l-1-i][l-1-j] = b
matrix[l-1-j][i] = c
return
```