What language is it in?
If I could do it in Perl I think I'd do something like:
1. Convert array 1 to a hash.
2. Iterate through array 2 and see if it exists in the hash.
Something like:
The code above runs on my iMac in the following time:
Dict and DictRev are files that contain 173122 words. They both contain the same words but DictRev is reversed. Sorting DictRev by general numeric value (sort -g) gets a similar process time.
If I had to do it in Java, I would probably put array1 into a hash table creating hashes of each word, then iterate through array2 creating a hash and seeing if it existed i the hash table.
Not sure on the inbuilt data structures of Cocoa, so not sure on my approach using Objective-C.