2022-09-01 01:01:22 +02:00
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class Solution {
|
2024-01-03 12:06:42 +01:00
|
|
|
public:
|
|
|
|
void rotate(std::vector<std::vector<int>> &matrix) {
|
2022-09-01 01:01:22 +02:00
|
|
|
for (std::size_t i = 0; i < matrix.size(); i++) {
|
|
|
|
for (std::size_t j = i; j < matrix.size(); j++) {
|
|
|
|
std::swap(matrix[i][j], matrix[j][i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-03 12:06:42 +01:00
|
|
|
for (auto &row : matrix) {
|
2022-09-01 01:01:22 +02:00
|
|
|
std::reverse(row.begin(), row.end());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|