Uber | Phone | Find the top k best selling food for each restaurant
Anonymous User
1197

Question: Imagine you are UBER EAT and you have to give top k best selling food report.
Find the top k best selling food for each restaraunt.
Input#1;
restaraunt_name, food_name
"RestaurantA", "apple"
"RestaurantA", "banana"
"RestaurantA", "apple"
"RestaurantB", "coke"
"RestaurantB", "coffee"
"RestaurantB", "coffee"
"RestaurantA", "banana"
"RestaurantA", "orange"

input#2 int k

k = 2
output:
RestaurantA => ["apple", "banana"]
RestaurantB => ["coke", "coffee"]

k = 3
output:
RestaurantA => ["apple", "banana", "orange"]
RestaurantB => ["coke", "coffee"]

Comments (7)