Build Every Mix of Cloud Credit Packs That Totals a Budget

Last updated: November 29, 2026

Quick Overview

Google Cloud sells credit packs in a few distinct denominations, and a customer may buy any pack any number of times. Return every distinct multiset of packs whose values sum exactly to the budget.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Google Cloud sells credit packs in a few distinct denominations, and a customer may buy any pack any number of times. Return every distinct multiset of packs whose values sum exactly to the budget.

Shows up in Google technical screens as a combination-sum style problem with a billing story. The interviewer checks reuse semantics (recurse on the same index), duplicate avoidance through non-decreasing order, and pruning on sorted input.

What the Interviewer Expects
  • Recurses with the same start index to allow unlimited reuse
  • Uses non-decreasing order so {5,10} and {10,5} are not both produced
  • Sorts and breaks early once a pack exceeds the remaining budget
  • Discusses exponential worst case and what bounds it
  • Contrasts with the DP that only counts mixes
Key Topics to Cover
Backtracking
Combination sum
Pruning
Unbounded choice
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you return only the mix with the fewest packs?
  • How would you count mixes for a budget of 10^5 without listing them?
  • What changes if each denomination has a purchase limit?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: distinct positive pack values, for example [2, 3, 6, 7], and a positive budget, for example 7.
  • Output: every multiset summing to the budget, each listed in non-decreasing order: `[2,2,3...
High-Level Design

Sort the denominations. The recursion state is (start, remaining). From a node we try each pack at index i >= start. Passing i (not i + 1) to the child lets the same pack be bought again, and ...


Submit Your Answer
Markdown supported