1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00

problems(swift): add “867. Transpose Matrix”

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2023-12-10 19:09:21 +01:00
parent 75305c4b8d
commit c1f7120274
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -0,0 +1,16 @@
class Solution {
func transpose(_ matrix: [[Int]]) -> [[Int]] {
var m = Array(
repeating: Array(repeating: 0, count: matrix.count),
count: matrix[0].count
)
for y in 0..<matrix.count {
for x in 0..<matrix[y].count {
m[x][y] = matrix[y][x]
}
}
return m
}
}