problems(kt): add „2133. Check if Every Row and Column Contains All Numbers“
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
1873ff8016
commit
f7ebb9037d
1 changed files with 13 additions and 0 deletions
|
@ -0,0 +1,13 @@
|
||||||
|
class Solution {
|
||||||
|
fun checkValid(matrix: Array<IntArray>): Boolean {
|
||||||
|
val n = matrix.size
|
||||||
|
val required = (1..n).toSet()
|
||||||
|
|
||||||
|
fun checkDimension(
|
||||||
|
dimensions: Iterable<Iterable<Int>>
|
||||||
|
): Boolean = dimensions.all { it.toSet() == required }
|
||||||
|
|
||||||
|
return checkDimension(matrix.map(IntArray::toList)) &&
|
||||||
|
checkDimension((0 until n).map { x -> matrix.map { row -> row[x] }})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue