Amazon Interview Question

Intersection of arrays

Interview Answers

Anonymous

Jan 25, 2011

is it arrays or linklists? It doesn't make much with arrays since arrays will be in their own separate memory. Or am I missing something here?

Anonymous

Jan 24, 2011

I assume they are sorted else it doesn't make much sense. If the first number is less than the second number, the second array was added onto the end of the first one, and just return the middle. Else Recursively binary search the array for when the left number is < than the right number and this the point they intersect.