Please allow me to ask this question with an example: Suppose we have the following 3 lists (outlined double quotes for clarity):
L1: (a, c, b, d, f, j) L2: (b, e, j, k) L3: (a, d, e, g, h, j, i)
The output list may look like any of the following (there are more solutions)
Lanswer1: (a, c, b, d, e, f, g, h, j, i, k) Lanswer2: (a, c, b, d, f, e, g, h, j, i, k) Lanswer3: (a, c, b, d, e, f, g, h, j, k, i)
As a result, the resulting ordered set
- Contains a union of elements from all lists
- The order of items in all source lists is maintained.
4th list, L4: (b, c, d), when added to an input, should throw an exception (since c comes before b in L1)
I came up with answers to check. Can anyone suggest an algorithm for this? Thank you, M.S.