I need your help because I'm a bit stuck with this issue.
I've got two list with repeated elements:
L = [1,2,5,2,4,1,9]
S =[4,2,9,1]
I want to get the "difference" between the two list, as if I do LS = L-S, and the result should be LS = [1,2,5].
I know that l2 will always be a subset of L, thus S will never have a value not present in L.
Note that only one 1 and one 2 has been removed from L, because there was only one 1 and one 2 in S. L can have elements repeated n times, not just 2 times.
Do you know if there's an "easy" way to do this? I wouldn't like to get an O(n^2) program.
Thank you so much!