General approach to dealing with combinations
This problem is yet another "combinations" problem, a common LC and interview question, here it is: Closest Dessert Cost - LeetCode 1774. Closest Dessert Cost Medium 87 13 Add to List Share You would like to make dessert and are preparing to buy the ingredients. You have n ice cream base flavors and m types of toppings to choose from. You must follow these rules when making your dessert: There must be exactly one ice cream base. You can add one or more types of topping or have no toppings at all. There are at most two of each type of topping. You are given three inputs: baseCosts , an integer array of length n , where each baseCosts[i] represents the price of the i th ice cream base flavor. toppingCosts , an integer array of length m , where each toppingCosts[i] is the price of one of the i th topping. target , an integer representing...