문제

해결
import Foundation
func sol(m: Int, n: Int, examples: [[Int]]) {
var matrix = Array(repeating: Array(repeating: 0, count: m), count: n)
for ex in examples {
let row = ex[0] - 1
let column = ex[1] - 1
let value = ex[2]
if row >= 0 && row < n && column >= 0 && column < m {
matrix[row][column] = value
}
}
for row in matrix {
for value in row {
print(value, terminator: " ")
}
print()
}
}
let exampleInput = [
[1, 2, 7],
[1, 3, 4],
[2, 1, 2],
[2, 3, 5],
[2, 5, 5],
[3, 4, 5],
[4, 2, 2],
[4, 5, 5],
[6, 4, 5]
]
sol(m: 6, n: 9, examples: exampleInput)