Amazon Interview Question
SDE1sCountry: India
cannot we use a database with table 'Product-Person' containing map of which product is viewed by which person.
Then its a simple SQL query to display products viewed people who also viewed current product
select product from product-person
where person in (select person from product-person where product='A')
Best Suited DS is Graph. Make each product as vertex. and have edge between different vertices and set relationship between edges. while performing BFS you will get you required ans.
- Anonymous August 28, 2014