Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
460 B
2
Indexable
Never
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]));
        }
    }
};
Leave a Comment