```
class Solution {
public:
void rotate(vector<vector<int>>& matrix) {
//swap based on diagonal
for(std::size_t i=0;i<matrix.size();++i){
for(std::size_t j=0;j<i;++j){
std::swap(matrix[i][j],matrix[j][i]);
}
}
//reverse earch row
for(std::size_t i=0;i<matrix.size();++i){
std::reverse(matrix[i].begin(),matrix[i].end());
}
}
};
```