class Solution {
public:
void rotate(vector<vector<int>>& matrix) {
vector<vector<int>> res;
vector<int> ans;
if(matrix.empty())
{
return ;
}
int top = 0;
int bottom = matrix.size()-1;
int left = 0;
int right = matrix[0].size()-1;
while(left<=right)
{
for(int i=bottom;i>=top;i--)
{
ans.push_back(matrix[i][left]);
}
left ++;
res.push_back(ans);
int n = ans.size();
while(n!=0)
{
ans.pop_back();
n --;
}
}
for(int i=0;i<res.size();i++)
{
for(int j=0;j<res[0].size();j++)
{
matrix[i][j] = res[i][j];
}
}
return ;
}
};