A = [a1, a2, a3...] #a1<a2<a3...
B = [b1, b2...] #b1<b2<b3...
A and B are disjoint. are I do not know the number of elements and the value of them in A/B in advance. I want to compare the value of the elements in both list and delete elements iff:
delete a[i+1] if there is no b[j] such that a[i]<b[j]<a[i+1]
delete b[i+1] if there is no a[j] such that b[i]<a[j]<b[i+1]
At the end, I want to separate list, not a combination of A and B.
For example, If A[0] < B[0], A = [1, 10, 40], B = [15, 30]. Compare A[1] and B[0] first. Delete 10 because no element in B are in between 1 and 15.
Then delete 15 since no element exist anymore btw 15 and 30. The output should be: if you try to order the elements of the new 2 lists, it should be A[0]<B[0]<A[1]<B[1]<...
If A[0] > B[0], vice versa.
returns:
and for
it returns
[3, 6]and[1, 5, 10].EDIT: another possibility: