Amazon Interview question
Suppose your team needs to launch a new recommendation feature called “Stuff Your Friends are Buying”. The recommendation logic is based on the following rules:
• A customer should only be recommended product that their friends bought but they haven’t bought.
• The recommendations priority is driven by how many friends have purchased the same item – if multiple friends purchased the same item, it should be higher in the recommendations than a product that only one friend owns.
You are provided two library functions to help you
• getFriendsListForUser – returns a list of customer IDs (strings that uniquely identify an Amazon user) representing the friends of an Amazon user
• getPurchasesForUser – returns a list of product IDs (strings that uniquely identify an item in the Amazon catalog) for an Amazon user ordered by purchase time with newest purchase first in list and oldest purchase last in list
For this evaluation, please:
1) Write a function that provides a ranked (high to low) list of recommendations (product IDs) for a provided user.
2) Write code for a few key unit tests for your code.
3) Enumerate other unit test scenarios (code not required).
4) Provide the space and time complexity of your solution.