```
public:
void rotate(vector<vector<int>>& matrix) {
//first transpose the matrix
int n = matrix.size();
for(int i = 0;i < n;i++)
for(int j = i + 1;j < n;j++)
swap(matrix[i][j], matrix[j][i]);
//then mirror the matrix by the vertical mid line
for(int i = 0;i < n;i++)
for(int j = 0;j < n / 2;j++)
swap(matrix[i][j], matrix[i][n - 1 - j]);
}
};
```