What you have here is a searching problem. You have two set sets of size n and m. The running time should be O((n log n) + (m log m)) since you need to find what elements in n are in m, and which ones are m that are in n.
The non theoretical answer is to use hashes and check the to see what keys exist in both..
---- Then B.I. said, "Hov' remind yourself
nobody built like you, you designed yourself"