Amazon.com Interview Question
1,580 Interview Reviews |
Back to all Amazon.com Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Development Engineer at Amazon.com:
You are given two arrays, design a method to produce the intersection of those arrays. Analyze its runtime.
See more for this Amazon.com Software Development Engineer Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (2)
table = {}
res = []
for i in arr1:
table[i] = 1
for i in arr2:
if table.has_key(i):
res.append(i)
return res
Run time is O(n+m)--linear and space is O(n+m). Not the prettiest solution but a quick one.
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up



1 of 1 people found this helpful
by Interview Candidate: