Get Best Price
Updated
Problem statement
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 🍻
Function
getBestPrice(menu: String[][], userWants: String[]) → floatExamples
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.0The 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 Onsite Interview questions
- Implement tail -nPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Sudoku Board ValidationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Sudoku Puzzle SolverPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Sequential Phrase Search Across DocumentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Bounded Combination Sum with Signed CandidatesONSITE INTERVIEW · Seen Oct 2026
- Detect a Silent SensorONSITE INTERVIEW · Seen Sep 2026
- Build an Inverted Document IndexONSITE INTERVIEW · Seen Sep 2026
- Combination Sum with Unlimited ReuseONSITE INTERVIEW · Seen Sep 2026
- Word Search Across DocumentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Windowed Key-Value MapPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
Similar questions at other companies
- Optimal Account BalancingAmazon · ONSITE INTERVIEW
- Count and Score Distinct Hat AssignmentsRoblox · ONSITE INTERVIEWRoblox interview questions
- Partition a Card Deck into FifteensMeta · ONSITE INTERVIEWMeta interview questions
- Maximum Currency Conversion Along a Simple PathRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
- Maximize Valid TrainsBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions
- Word Break IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Word Break II: All SentencesMicrosoft · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
- Maximum Ad Revenue With a Rolling-Window CapGoogle · ONSITE INTERVIEWGoogle interview questions
- Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
- Enumerate Right-and-Down Matrix PathsOracle · ONSITE INTERVIEWOracle interview questions