I am interested in finding the lines where all entries are equal to zeros except for one.

Example: Given the follwoing matrix:

\begin{bmatrix}0 &0 &3 & 8\ 0 & 4 & 0 & 0 \ 0 &1 & 0 & 1\end{bmatrix}

Only the second line verify this property.

Of course, the brute force way is to go over the entries and check them one by one. But I am wondering if there is another most efficient way I don’t know about.