The question asks to find an ith row and ith column such that the ith row only contains zeros, ane the ith column only contains ones (what is at their intersection doesn't matter) in linear time. If an i that satisfies this condition doesn't exist, just return -1. Here is the best I could come up with:
def zero_one(X):
X = numpy.array(X)
N = len(X)
for i in range(N):
original_value = X[i][i]
X[i][i] = 0
r = binaryToDecimal(X[i, :])
X[i][i] = 1
c = binaryToDecimal(X[:, i])
if r == 0 and c == 2**(N - 1) - 1:
X[i][i] = original_value
return i
X[i][i] = original_value
return -1 # in case there's no i that satisfies the condition
Assuming that binaryToDecimal() runs in linear time and column-wise like in NumPy is available, this could be linear, but I doubt it.