Problem · Dynamic Programming
Maximum Profit from Ticket Bundles
Learn this problemProblem statement
You are given an integer array prices, where prices[i] is the profit from selling a bundle of exactly i + 1 tickets.
You must sell exactly m tickets. You may use any combination of bundle sizes, and each bundle size may be used multiple times.
Return the maximum total profit obtainable by selling exactly m tickets.
Function
maxTicketBundleProfit(prices: int[], m: int) → intExamples
Example 1
prices = [10,70,30]m = 3return = 80The best choice is one 1-ticket bundle and one 2-ticket bundle, for total profit 10 + 70 = 80. Selling one 3-ticket bundle gives profit 30.
Constraints
1 <= m <= prices.lengthprices.lengthgives the largest available ticket-bundle size.