1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00
LeetCode/cpp/rotate-image.cpp
Matej Focko b229608723
cpp(chore): add clang-format style and format
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-01-03 12:06:54 +01:00

17 lines
428 B
C++

#include <algorithm>
#include <vector>
class Solution {
public:
void rotate(std::vector<std::vector<int>> &matrix) {
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]);
}
}
for (auto &row : matrix) {
std::reverse(row.begin(), row.end());
}
}
};