Shopping Offers
Starter Contract
The starter function is solve(price, special, needs). Each special row has
one quantity for every item followed by the offer price. Return the minimum
cost for exactly needs, using an offer only when every item quantity fits.
Given item prices and special offers (bundles of items at a discounted price), find the minimum cost to purchase exactly the required quantities of each item. You may use any number of each special offer.
Examples
Input: [[2,5],[[3,0,5],[1,2,10]],[3,2]]
Output: 14
Input: [[2,3,4],[[1,1,0,4],[2,2,1,9]],[1,2,1]]
Output: 11
Hints
Use DFS/backtracking to try using special offers.
For each state, try all special offers that fit.
Also try buying individual items without offers.
Related Problems
Shopping Offers
The starter function is `solve(price, special, needs)`. Each `special` row has