I have 3 list of data and I need to merge and maintain the order of insertion and there should not be any duplicates,
For Eg:
List l1=new LinkedList<>();
l1.add("b");
l1.add("a");
l1.add("o");
List l2=new LinkedList<>();
l2.add("m");
l2.add("n");
List l3=new LinkedList<>();
l3.add("m");
l3.add("n");
l3.add("o");
After merging the value should be
First Merging b a o m n
Second merging b a m n o
The input won't get modify in its order. If the value exist in first and it should be on first only.
EDIT to include OP's additional requirement:
the record in first should not move to middle. In case l3.add("b"); at first then the record should give [a, m, b, n, o] but we have b in first list(l1) as well and it should be b,a,m,n,o.