Maximum Books From Bundles
Updated
Problem statement
Given a budget budget and book bundles where bundle i has bundleQuantities[i] books and costs bundleCosts[i], return the largest number of books you can buy without spending more than budget. You may buy any bundle any number of times.
Function
maxBooks(budget: int, bundleQuantities: int[], bundleCosts: int[]) → intExamples
Example 1
budget = 50bundleQuantities = [20,19]bundleCosts = [24,20]return = 40Two bundles of 20 books cost 48.
Example 2
budget = 4bundleQuantities = [1]bundleCosts = [5]return = 0The only bundle costs 5, which is more than the budget of 4, so no books can be bought.
Constraints
- 1 <= budget <= 10^4
- 1 <= bundleQuantities.length == bundleCosts.length <= 100
- 1 <= bundleQuantities[i], bundleCosts[i] <= 10^4
More Patreon interview questions
Similar questions at other companies
- Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
- Maximum Beauty by DeletionsMeesho · OA
- Card Game: Best First-Player ScoreShopify · OAShopify interview questions
- Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
- 0/1 KnapsackConfluent · OAConfluent interview questions
- Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
- Maximum Subarray SumStraive · OA
- Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
- Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
- Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions