I need an algorithm to determine if an array contains two elements that sum to a given integer.
The array is sorted.
The algorithm should be recursiv
I think hash is ok, for example, 1,3,7,9,12,14,33...
if we want sum=21, we hash the numbers into a hash table, So, O(n).
we iterator them, when we get 7, we let 21-7=14, so we hash 14, we can find it. so 7+14=21,
we got it!