Rotate Image in Rust

impl Solution {
    fn rotate(matrix: &mut Vec<Vec<i32>>) {
        let n = matrix.len();

        // Step 1: Transpose the matrix
        for i in 0..n {
            for j in i..n {
                // Start from 'i' to avoid re-swapping
                let temp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = temp;
            }
        }

        // Step 2: Reverse each row
        for row in matrix.iter_mut() {
            row.reverse();
        }
    }
}

Next