I need a data structure representing a set of sequences (all the same, known, length) with the following non-standard operation:
Find two sequences in a set that differ in exactly one index. (Or establish that such a pair does not exist.)
If N is the length of the sequences, and M is the number of sequences, then there is an obvious algorithm O(N*M*M) . I wonder if there is a standard way to solve this more efficiently. I am ready to apply pre-processing if necessary.
Bonus points, if instead of returning a pair, the algorithm returns all sequences that differ at the same point.
Alternatively , I am also interested in a solution in which I can effectively check whether a particular sequence in one index differs from any sequence in a set. If this helps, we can assume that in the set no two sequences have this property.
Edit: N can be considered small enough. By this, I mean that improvements like O(log(N)*M*M) are not immediately useful for my use.
source share