How can I merge/extend a list to include the elements in another list which contains more information? The problem is the index where shifting occurs is not constant.
[1,2,3,4], [2,3,4,5], [5,6,7,8], [7,8,9,10] into [1,2,3,4,5,6,7,8,9,10]
Lists are a timed snapshot of a time sereis so the sequence and order of the elements should remain and duplicate elements are allowed i.e
[1,2,3,4,5,5,6,7,8] and [4,5,5,6,7,8,9,10,11]
the second list contains elements from the first list and more, you could say the second list is the same as the first but it has been shifted to the left and more elements added to it.
For example
l1 = [1,2,3,4,5,5,6,7,8]
l2 = [4,5,5,6,7,8,9,10,11]
results to
l3 = [1,2,3,4,5,5,6,7,8,9,10,11]
As per your second example, even duplicates are allowed. Therefore you can use a dictionary to keep track of elements in first list, along with their counts and compare it with the second list and append/update accordingly.
Output: