Meta Interview Question

Try to improve the intersection question by binary search, but I did not finish the coding.

Interview Answers

Anonymous

Dec 19, 2014

You should have started with 2 pointers i,j one for each array, always increment the pointer for the array that has the minimum value between a[i] and b[j]. If you ended one array, continue the other until a[i]>b[b.length()-1] This has complexity 0(n+m). Your algo has complexity O(nlogm) for searching if all elements in n are in m

1

Anonymous

Jan 4, 2015

Walk from nodes to the root filling up hashtables with passed nodes. On every step check if current node is present in hashtable of another node.