Given an array A (n X n), which takes values from set {0, 1}; i.e.
A[i][j]= 0 or 1 for all i,j between 0 and n
Find a row i such that all elements in the row are 1s and a column j such that all elements are 0 except the intersecting element A[i][j] which is 1.
Another version of the same problem goes like this:
Given that every row of the array has all 1s and 0s together and 0s follow only after 1s in the row, find the maximum number of 1s in a row in the array.
Hint: O(n2) is a naive algorithm and O(n) is nice.
1 year ago
No comments:
Post a Comment