Amazon Interview Question for Software Engineer / Developers


Team: RCX
Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
1
of 1 vote

I would make it similar to a dictionary problem.

Make use of trie to store the product-list.
so if a customer adds Product A to the cart then display the top n children of the node A.

similar to suggesting/displaying words starting with A in T9 dictionary implementation.

- n1k41| January 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We need to have a Product-Product relationship (like a sparse matrix).
So, if the system has 'n' products, our matrix will be of the size nxn.
Each cell contains integer values.

Given a product 'i' and asked to find the other products that were bought along with 'i', we just lookup the ith row in the matrix, and return all the column indexes j such that value[i][j] is not zero.

- Learner February 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

The Product-Product relationship table should be implemented intelligently, like there should be a minimum threshold that atleast 'k' transactions had both the products together.

- Learner May 03, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I could use Sphinx search as a solution for this.
Create a real time sphinx index with schema:

id as sql_attr_uint, (auto increment)
main_product_id as sql_field_string,
other_product_id as sql_field_string

I would write inserts to this index for products bought 2 or more,
for example product ids 100, 200, 300 bought together then:
insert (main_product_id, other_product_id) values ((100,200), (100,300), (200, 300), (200,100), (300, 100), (300, 200));

To identify other products sorted by most bought when buying product 100 then do:
select @groupby, @count from index where match('@main_product_id 100') group by other_product_id order by @count desc;

Note: @groupby will become an alias of other_product_id and @count shows the number of times it was bought.

- Anonymous January 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

I could use Sphinx search as a solution for this.
Create a real time sphinx index with schema:

id as sql_attr_uint, (auto increment)
main_product_id as sql_field_string,
other_product_id as sql_field_string

I would write inserts to this index for products bought 2 or more,
for example product ids 100, 200, 300 bought together then:
insert (main_product_id, other_product_id) values ((100,200), (100,300), (200, 300), (200,100), (300, 100), (300, 200));

To identify other products sorted by most bought when buying product 100 then do:
select @groupby, @count from index where match('@main_product_id 100') group by other_product_id order by @count desc;

Note: @groupby will become an alias of other_product_id and @count shows the number of times it was bought.

Q. What if memory is not sufficient?
A. Sphinx runs in fixed memory which we can pre-define.

Q. How do DB tables look like?
A. one MySql table and one sphinx index with same schema as above. Ofcource we need to a mysql lookup table with product id and description.

Q. If you use multiple DB calls for every request, it may be very inefficient as you might be serving millions of requests. can you improve?
A. One sphinx call is enough for 'Customers who bought also bought' to be done.

Q. Can you state what all components are present in the system and how does the control flow after webserver receives the request?
????

- sandeepboda91083 January 09, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More