I have two flat lists in which one of them contains duplicate values. For instance,
array1 = [1,4,4,7,10,10,10,15,16,17,18,20] array2 = [4,6,7,8,9,10]
I need to find the values ββin array 1, which are also in array2, SAVING DUPLICATES in array 1. The desired result will be
result = [4,4,7,10,10,10]
I want to avoid loops as the actual arrays will contain more than a million values. I tried various combinations of sets and intersections, but just couldn't keep duplicates.
Any help would be greatly appreciated!