MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / transpose

Function transpose

867-transpose-matrix.rs:1–12  ·  view source on GitHub ↗
(matrix: Vec<Vec<i32>>)

Source from the content-addressed store, hash-verified

1pub fn transpose(matrix: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
2 let times = matrix[0].len();
3 let mut res = vec!();
4 for i in 0..times {
5 let mut tmp = vec!();
6 for e in &matrix {
7 tmp.push(e[i]);
8 }
9 res.push(tmp);
10 }
11 res
12}
13
14fn main() {
15 let matrix = vec![vec![1,2,3],vec![4,5,6]];

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected