2022-09-09 18:58:35 +02:00
|
|
|
class Solution {
|
|
|
|
fun checkValid(matrix: Array<IntArray>): Boolean {
|
|
|
|
val n = matrix.size
|
|
|
|
val required = (1..n).toSet()
|
|
|
|
|
2024-05-17 18:23:38 +02:00
|
|
|
fun checkDimension(dimensions: Iterable<Iterable<Int>>): Boolean = dimensions.all { it.toSet() == required }
|
2022-09-09 18:58:35 +02:00
|
|
|
|
|
|
|
return checkDimension(matrix.map(IntArray::toList)) &&
|
2024-05-17 18:23:38 +02:00
|
|
|
checkDimension((0 until n).map { x -> matrix.map { row -> row[x] } })
|
2022-09-09 18:58:35 +02:00
|
|
|
}
|
|
|
|
}
|