
I think that i need to use binary search to solve this problem because of the time limit. Can someone explain to me binary search?
[ Moze i na srpskom. :) ]

This should help
http://en.wikipedia.org/wiki/Binary_search

You can use a STL container that implements a binary search (Or containes of other the lenguague you use). The examples are a set and a map.

i used a set and put elements into the set for first half, in second half u check if the elements are there, really fast.
u can also use the inbuilt binary search in <algorithm> header. :D

I've solved it finaly. :)
Little hint : If array A is [ aleksandar, ivanovic ] and array B is [ aleksandar, aleksandar ] you should output 2 instead of 1. :)