48. Rotate Image

来源:互联网 发布:java session取不到值 编辑:程序博客网 时间:2024/06/08 07:46

class Solution {
public:
void rotate(vector<vector<int>>& matrix) {
int len = matrix.size();
vector<vector<int> >res;
vector<int >temp;
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
{
temp.push_back(matrix[len - j-1][i]);
}
res.push_back(temp);
temp.clear();
}

for (int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
{
matrix[i][j] = res[i][j];
}
}

}
};

0 0
原创粉丝点击