A very difficult question, but I will give him a chance. This is more a stream of consciousness than an answer, sorry in advance.
If I understand this correctly, you are given 2 identical string sequences, A and B, indexed from 1..n, say. Then you need to find a sequence of indices such that the string concatenation A (1) .. A (m) is equal to the string concatenation B (1). B (m), where m is the length of the sequence of indices.
The first thing I would like to notice is that there can be an infinite number of solutions. For example, given:
A {"x", "xx"}
B {"xx", "x"}
Possible solutions:
{12}
{2, 1}
{1, 2, 1, 2}
{1, 2, 2, 1}
{2, 1, 1, 2}
{2, 1, 2, 1}
{1, 2, 1, 2, 1, 2}
...
So how would you know when to stop? Once you have one solution? As soon as one of the solutions is a superset of the other solution?
One place you could start is to take all the lines of minimum total length from both sets (in my example above, you should take an “x” from both and look for 2 equal lines that have a common index. Then you can repeat this for lines of the next size up. For example, if the first set has 3 lines of length 1, 2 and 3, respectively, and the second set has lines of length 1, 3 and 3, respectively, you should accept lines of length 3. You would do this while you had there will be no more lines, if you find anything, then you have a solution to the problem.
Then it gets harder when you need to start combining multiple lines, as in my example above. A naive and crude approach would be to start rearranging all the strings from both sets, which, when concatenated, lead to strings of the same length, and then compare them. So in the example below:
A {"ga", "bag", "ac", "a"}
B {"ba", "g", "ag", "gac"}
You start with sequences of length 2:
A {"ga", "ac"}, B {"ba", "ag"} (indices 1, 3)
A {"bag", "a"}, B {"g", "gac"} (indices 2, 4)
Comparing them, we get “gaac” versus “baag” and “baga” versus “ggac”, none of which are equal, so there are no solutions. Then we will look for sequences of length 3:
A {"ga", "bag", "a"}, B {"ba", "g", "gac"} (indices 1, 2, 4)
A {"bag", "ac", "a"}, B {"g", "ag", "gac"} (indices 2, 3, 4)
Again, there are no solutions, so we get sequences of size 4, of which we have no solutions.
Now it’s getting even more complicated, as we need to start thinking about perhaps repeating some indicators, and now my brain is melting.
I think that finding common subsequences in strings might be useful, and then use the rest of the strings that were not matched. But I do not quite understand how.