From 0a8bf37562e5fd43e663119654736d45ccce872a Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Thu, 2 Jun 2022 23:44:15 +0100 Subject: [PATCH] transpose-matrix --- transpose-matrix/sol.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 transpose-matrix/sol.rs diff --git a/transpose-matrix/sol.rs b/transpose-matrix/sol.rs new file mode 100644 index 0000000..b04bcc5 --- /dev/null +++ b/transpose-matrix/sol.rs @@ -0,0 +1,12 @@ +impl Solution { + pub fn transpose(matrix: Vec>) -> Vec> { + let n = matrix[0].len(); + (0..n).into_iter() + .map(|i| matrix + .iter() + .map(|row| row[i]) + .collect() + ) + .collect() + } +} \ No newline at end of file