Amazon interview question

Find duplicate elements in two lists

Interview Answers

Anonymous

Feb 11, 2016

If there are no space constrains, then convert one of the arrays into hashtable in O(m), and iterate over the other array to find if the value exists in the hashtable in O(n). Total O(m+n).

3

Anonymous

Feb 3, 2016

Sort the smaller list. Then binary search each element in the sorted array. mlogm + nlogm = (m+n)logm

1

Anonymous

Feb 8, 2016

how long did it take to get the final desicion after the phone interview?

2