Hi,
Let me try to slightly present the problem in a different way.
1. First go through the unsorted array and get two smaller arrays. One
array containing numbers <= z/2 and other array containing numbers >
z/2 and <= z. Other numbers obviously can be ignored.
2. Now 'z' complement(i.e. number = z - number) all the numbers in the
array which has numbers <= z/2.
3. The problem now is to find if any number in this complement array
repeats in the other array in O(n) time.
Am currently trying to find a solution to this.... will get back as
soon as I get an answer.