Skip to content

Commit 8c20341

Browse files
committed
2 parents 828921d + 402e10a commit 8c20341

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)