rotate image
code
class Solution {
public:
void rotate(vector<vector<int>>& matrix) {
vector<vector<int>> ret;
int m = matrix.size();
int n = matrix[0].size();
for(int i = 0; i<n; i++)
{
vector<int> tmp(m, 0);
ret.push_back(tmp);
}
for(int i = 0; i<m; i++)
{
for(int j = 0; j<n; j++)
{
ret[j][m-1-i] = matrix[i][j];
}
}
matrix = ret;
}
};