I saw a interview question as follows: Give an unsorted array of integers A and and an integer I, find out if any two members of A add up to I.
any clues?
ti
Split the array into two groups <= I/2 and > I/2. Then split those into <= I/4,>I/4 and <= 3I/4,>3I/4 And repeat for log(I) steps and check the pairs joining from the outside e.g 1I/8<= and >7I/8 and if they both contain at least one element then they add to I. This will take n.Log(I) + n/2 steps and for I