jx33wang
BAN USER
Comments (4)
Reputation 25
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
2
of 2 vote
You can do this in linear time.
A. Find Duplicates in Arr1 and Arr2:
1. Add each element in arr1 into a hashmap.
2. Iterate through each element in arr2; if exists in hashmap then add element to arr4
B. Find Uniques in Arr3 and Arr4:
1. Add each element in arr3 into a (new) hashmap.
2. Iterate through each element in arr4; if exists in hashmap then remove from hashmap. If does not exist in hashmap, then add to outputs.
3. add remaining elements from hashmap into outputs.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
This looks like a homework problem..
- jx33wang October 04, 2013