Skip to content

Commit d24b83c

Browse files
authored
Create 0867-transpose-matrix.kt
1 parent 027cb6c commit d24b83c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

kotlin/0867-transpose-matrix.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
fun transpose(matrix: Array<IntArray>): Array<IntArray> {
3+
val m = matrix.size
4+
val n = matrix[0].size
5+
val res = Array (n) { IntArray (m) }
6+
7+
for (i in 0 until m) {
8+
for (j in 0 until n) {
9+
res[j][i] = matrix[i][j]
10+
}
11+
}
12+
13+
return res
14+
}
15+
}

0 commit comments

Comments
 (0)