Untitled

Anonymous
plain_text
08/27/2024 11:04 AM
616 B
24
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