Possible Duplicate:
Determine whether or not there exist two elements in Set S whose sum is exactly x - correct solution?
Consider an unsorted array of numbers and an constant Z. We want to find whether there are two elements in the array whose sum is Z.
I know there is an O(n*lgn) algorithm to do so. But is there an algorithm that run in O(n) average case?