← 返回 amazon 的题目列表Friend Purchase Recommendation
类型:online_judge
Given a user structure with friends and purchased products, provide a function to find the product names bought by friends but not by the user.
Input/Output
Input:
User object user including:
friends: list of friends, each friend is a user object
purchases: list of purchases, each purchase is an object containing productId
Output:
List of strings representing recommended product names.
Example
Assume a product list:
products = {
"p1": "Product 1",
"p2": "Product 2",
"p3": "Product 3",
}
User A:
Purchases: ["p1"]
Friends: [User B]
User B:
Purchases: ["p1", "p2", "p3"]
Function output should be: [Product 2", "Product 3"]`.
Example
Input
Generate input based on example provided