# How to efficiently find elements in list A that aren't in list B?

Every element in List A appears only once, and the same is true for List B. How can I efficiently create a list of the element in A that don't appear in B? Obviously, I can just do this:

Do[A=DeleteDuplicates[A,B[[i]]],{i,1,Length[B]}];


...but that's painfully slow for very long lists. Also, it doesn't take advantage of my knowledge that every element in each list is unique within the list.

Thanks!

• Complement[B, A] ? – cvgmt Mar 7 at 23:15
• @cvgmt Seriously, that simple? Well, if you want to post that as an Answer, I'll Accept it. – Jerry Guern Mar 7 at 23:17

A = RandomInteger[10, 10]