Untitled

mail@pastecode.io avatar
unknown
rust
a month ago
468 B
2
Indexable
Never
impl Solution {
    pub fn rotate(a: &mut Vec<Vec<i32>>) {
        let n = a.len() - 1;

        for k in 0..n / 2 + 1 {
            let m = n - k;
            for p in k..m {
                let t1 = a[k + p][m];
                a[k + p][m] = a[k][k + p];
                let t2 = a[m][m - p];
                a[m][m - p] = t1;
                let t3 = a[m - p][k];
                a[m - p][k] = t2;
                a[k][k + p] = t3;
            }
        }
    }
}

Leave a Comment