A food delivery service wants to help customers minimize the total cost of ordering a specific set of dishes from a restaurant menu.
"<item1>,<item2>,...".userWants, a list of unique item names they wish to obtain.Your task is to find all unique combinations of menu entry IDs such that:
userWants.userWants can be ignored.Return a list of all unique combinations of menu entry IDs (in any order within each combination) that achieve the minimum total cost and cover all items in userWants.
If it is impossible to fulfill the order, return an empty list.
Note: Each combination must be returned as a list of IDs. The order of IDs within a combination is unimportant, and the combinations themselves may be returned in any order. For floating-point comparisons, consider two total costs equal if their difference is within an epsilon of 1e-6.
Constraints:
menu.length ≤ 100userWants.length ≤ 20userWants is unique.Example 1:
Input: menu = [["1", "5.00", "pizza"], ["2", "8.00", "sandwich,coke"], ["3", "4.00", "pasta"], ["4", "2.00", "coke"], ["5", "6.00", "pasta,coke,pizza"], ["6", "8.00", "burger,coke,pizza"], ["7", "5.00", "sandwich"]], useWants = ["sandwich", "pasta", "coke"]
Output: [["3", "4", "7"], ["5", "7"]]
Explanation: One optimal way is to select menu entries with IDs "3" (pasta), "4" (coke), and "7" (sandwich), which totals 11.00. Alternatively, you can choose "5" (pasta, coke, pizza) and "7" (sandwich), also totaling 11.00. Both options achieve the minimum possible total cost.
Example 2
Input: menu = [["1", "5.00", "pizza"], ["2", "8.00", "sandwich,coke"], ["3", "4.00", "pasta"], ["4", "2.00", "coke"], ["5", "6.00", "pasta,coke,pizza"], ["6", "8.00", "burger,coke,pizza"], ["7", "5.00", "sandwich"]], userWants = ["burger", "pasta"]
Output: [["3", "6"]]
Example 3
Input: menu = [["1", "5.00", "specialItem"], ["2", "10.00", "specialItem,extra1"], ["3", "8.00", "specialItem,extra2"], ["4", "15.00", "specialItem,extra1,extra2"]], userWants = ["specialItem", "nonExistingItem"]
Output: []