So, I have two lists which may have overlapping sublists. In that case, I want to delete one sublist.
The actual data comes from a binary tree, so if tree format is better, we can pursue that angle instead. But basically I want to do this:
List1: [1, 1, 2, 3, 5, 8, 7, 7, 4]
List2: [3, 5, 5, 8, 12, 15]
match: [5, 8]
(specifically in that order, as a set, not matching each number every time it shows up)
newList1: [1, 1, 2, 3, 7, 7, 4]
List 2: unchanged
I can’t use set operations because I need them in identical order and allowing duplicates. Tree form is hard to think through for me, which is why I am approaching this as a list problem, but as a tree problem, it would be that:
A
/ \
B E
/ \ \
C D F
/ \
H I
/
J
Branch J matches Branch F perfectly, thus delete Branch F and keep the rest of the tree unchanged.