Expedia Interview Question
Software Engineer / DevelopersI used a hashtable(on smaller) for detecting intersection. After populating the hashtable, I overwrote the smaller array.
If all the elements in the smaller array, at worst, are in the bigger array, then the returned array is sizeof(smaller array). Any other case is < the size of the smaller array.
By the way, my interview with CME today raised a good point. You should clarify why you're using an array, hashtable, hashmap, or any that is wrapped with hashing. Although lookup is O(1), lookup internally might be get inefficient. For instance, a hashmap may wrap a BST, O(logn), or a hashtable may wrap an array O(1).
Can you please tell me what answer you gave for intersection of two arrays. I was asked the same question at one place.
- Anna April 04, 2006