A = ['a','b','c']
B = ['d','b','e']
res = [i for i in A if i in B]
The above code does not work when the no of elements in A are 300000 and in B are 200000.
How can I solve it?
I also tried
res = {i for i in A if i in B}
res = list(res)
But still could not get the result.