Python 2, 49 bytes
Takes as input a 2D binary matrix \$ a \$, and its size \$ n \$.
lambda a,n:sorted(map(sum,a+zip(*a)))[-2:]==[1,n]
There may be shorter approaches, but this is what I could find for now. Please let me know if the algorithm is incorrect.
dingledooper
- 23.4k
- 1
- 40
- 130