My question is generalizable to arrays of any type but I'll use strings to keep it short.
We take a couple of strings as an input. Let's denote them ${S_1,...S_n}$. (Ex: "ABEF" and "CDE"). The output $U$ must fulfill the following conditions:
- The output must contain the entire "vocabulary" of all of the inputs and not more: $x\in U \Leftrightarrow \exists i : x\in S_i$
 - Each element in the output appears only once in the output.
 - The elements in the output keep their relative ordering from their original strings. So if 'A' comes before 'B' in the string $S_i$, then 'A' must come before 'B' in the output $U$.
 
The problem can have multiple solutions or no solutions. I'm fine with finding just one of them. Some examples might be:
| inputs | possible solutions | 
|---|---|
| ABEF, CDE | ABCDEF, CDABEF, CABDEF... | 
| ABEF, CDE, BC | ABCDEF (only solution) | 
| ABEF, CDE, CB | CDABEF, CADBEF, ... | 
I found this question with a similar algorithm. However, their algorithm allows repeated elements in their output.
Is there a name for this algorithm? What's the time complexity? Does anyone know an implementation in a Python library? Thanks!
Clarifications:
- the inputs do not have an ordering. The ordering is given by the inputs themselves. That's why "CDABEF" is a valid solution in the first example.
 - If the problem does not have a solution, throw an exception.