A no-intersecting ones matrix is one where no two ones exist on the same row or column.
To illustrate:
[
[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0]
]
The list below is not a non-intersecting ones matrix:
[
[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 0, 1, 0],
[0, 1, 0, 0, 0],
[0, 0, 0, 0, 0]
]
// Column 2 has two 1s.
Write a function that returns True if a 2D matrix is a no-intersecting ones matrix and False otherwise.
no_intersecting_nes([
[0, 1],
[1, 0]
]) ➞ True
no_intersecting_ones([
[1, 1],
[0, 0]
]) ➞ False
no_intersecting_ones([
[0, 0, 0, 1],
[1, 0, 0, 0],
[0, 1, 0, 0]
]) ➞ True
N/A