Untitled
unknown
plain_text
a year ago
460 B
9
Indexable
class Solution {
public:
void rotate(vector<vector<int>>& matrix) {
cin.tie(nullptr)->sync_with_stdio(0);
int n = matrix.size();
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
swap(matrix[i][j], matrix[j][i]);
}
}
for (int i = 0; i < n; i++) {
reverse(matrix[i].begin(), end(matrix[i]));
}
}
};
Editor is loading...
Leave a Comment