leet-code/transpose-matrix/sol.rs

12 lines
297 B
Rust
Raw Permalink Normal View History

2022-06-02 22:44:15 +00:00
impl Solution {
pub fn transpose(matrix: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
let n = matrix[0].len();
(0..n).into_iter()
.map(|i| matrix
.iter()
.map(|row| row[i])
.collect()
)
.collect()
}
}