link mingle home | logged in as: guest | login/register| submit link


IndiaDiscuss.com : Social Bookmarkings and News Networking Site for India
interview_questions
Bookmarks
Intersection of Arrays
5
Votes

Write a function to find intersection of two arrays?

saved under Amazon Interview Questions by interview_questions

 
1. For i=0 to A.length 2. If (Find(B, A[i]) == True) 3. Intersection.add(A[i]) 4. Return Intersection
comment by sachidanand on 2009-09-29 09:50:26
Sort the two arrays in O(NlogN).Then find the intersection in O(N)
comment by imrankane2005 on 2009-12-27 10:13:03
I think we sorting one array of smaller size is enough. Then just traverse bigger array and find the number in smallery array using binary search.
comment by aravinds03 on 2010-09-25 15:21:58
 



Enter the string above
 
IndiaDiscuss | Published News | Hot
Indian Social News and Links Network
IndiaDiscuss | Published News
Indian Social News and Links Network