Given two sequences s1
and s2
, a supersequence of s1
and s2
is another sequences with length less than the sum of the lengths of s1
and s2
and that contains them. For example, for s1=[1,2,4,4]
, and s2=[4,4,9,7]
, a supersequence may be [1,2,4,4,9,7]
, and also [1,2,4,4,4,9,7]
.
I am trying to find an efficient implementation of a function f
whose inputs are two sequences s1
and s2
and that does the following: first, compute the number of possible supersequences and then returns the position where the overlapping takes place (for simplicity, let's assume s1
always appears first in the supersequences).
For instance, taking the previous example, f([1,2,4,4], [4,4,9,7])
should return 2
and 3
, the indexes where the second sequence starts in the two existing supersequences.