We have three lists which contain people's names.
All three lists have been sorted alphabetically.
Now we need to find at least one name which appear in all three lists.
The algorithm I am thinking is like this:
I get three heads out of three lists.
if the three heads are not equal to each other, then I keep the max one and get two new heads from the lists from which I just dropped the heads.
Continue above procedure until I find such an element as described in the beginning.
Is this algorithm correct?
The problem is that I am not sure how to use ocaml to write the function.