Problem · Dynamic Programming
Get Best Price
You are building an App that lets the users determine the most cost-effective order that they can place in a restaurant for the food items that they want to have. You have the menu of the restaurant that contains item name, and it's price. The restaurant can also offer Value Meals, which are groups of several items, at a discounted price. Write a program that accepts a list of menu items, and a list of items that the user wants to eat, and outputs the best price at which they can get all of their desired items.
To hhbond 🍻
Examples
01 · Example 1
menu = [["5.00", "pizza"], ["8.00", "sandwich, coke"], ["4.00", "pasta"], ["2.00", "coke"], ["6.00", "pasta, coke, pizza"], ["8.00", "burger, coke, pizza"], ["5.00", "sandwich"]] userWants = ["burger", "pasta"] return = 12
The user wants to order "burger" and "pasta". The best price can be achieved by ordering the following:
"pasta" for 4.00
"burger, coke, pizza" for 8.00
This gives us the total best price of 4.00 + 8.00 = 12.00.
(By tomtato, it may not be 100% correct)
Constraints
The user can order a maximum of 3 unique items.More Confluent problems
public float getBestPrice(String[][] menu, String[] userWants) {
// write your code here
}
menu[["5.00", "pizza"], ["8.00", "sandwich, coke"], ["4.00", "pasta"], ["2.00", "coke"], ["6.00", "pasta, coke, pizza"], ["8.00", "burger, coke, pizza"], ["5.00", "sandwich"]]
userWants["burger", "pasta"]
expected12
sign in to submit