FastPrepMaximum Books From Bundles
Problems/Maximum Books From Bundles

Maximum Books From Bundles

Patreon logoPatreon● MediumINTERNOA

Updated Dec 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Patreon software engineer intern HackerRank online assessment. The candidate described buying as many books as possible, given the sizes and prices of book bundles.

The report does not mention a budget, whether a bundle can be bought more than once, or any limits. Here a budget is given, any bundle can be bought again, and the limits are our practice assumptions.

Our version is about 70% the same as the reported question.

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[]) → int

Examples

Example 1

budget = 50bundleQuantities = [20,19]bundleCosts = [24,20]return = 40

Two bundles of 20 books cost 48.

Example 2

budget = 4bundleQuantities = [1]bundleCosts = [5]return = 0

The 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

  • Sum of Subarray RegionsOA · Seen Oct 2024
  • Three SumOA · Seen Sep 2024
  • Binary Cardinality SortingOA · Seen Apr 2023
  • Professors Teaching Outside Their DepartmentOA · Seen Apr 2023
  • Sliding-Window API Rate LimiterPHONE SCREEN · Seen Oct 2026

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
All Patreon interview questionsSee Patreon hiring insights
Saved
class Solution {
    public int maxBooks(int budget, int[] bundleQuantities, int[] bundleCosts) {
        // write your code here
    }
}
Checking account…