Enumerate Distinct Coupon Bundles From a Pool With Repeated Codes

Last updated: November 29, 2026

Quick Overview

A Google Store promo pool contains coupon codes, some repeated. Return every distinct multiset (bundle) of coupons that can be drawn from the pool, with no duplicate bundles in the output.

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

0

0

0 solved


A Google Store promo pool contains coupon codes, some repeated. Return every distinct multiset (bundle) of coupons that can be drawn from the pool, with no duplicate bundles in the output.

A Google technical screen staple that starts like plain subsets and then adds duplicates. The interviewer wants to see you sort and skip equal siblings at the same recursion depth rather than dedupe with a set after the fact.

What the Interviewer Expects
  • Sorts the input so equal values are adjacent
  • Skips a duplicate only when it is a sibling at the same depth, not when it is a child
  • Explains why a post-hoc set of tuples is correct but wasteful
  • Gives complexity in terms of output size
  • Tests with all-equal input
Key Topics to Cover
Backtracking
Duplicate pruning
Sorting
Multisets
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 many bundles are there if code c appears k_c times?
  • How would you return only bundles whose total discount is at most a budget?
  • Can you do this iteratively by extending only the subsets added in the last round?
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: a list of coupon codes (strings or ints), for example ["A", "B", "B"].
  • Output: every distinct bundle, each as a sorted list. ["A","B"] must appear once even though either B could be cho...
High-Level Design

Sort the pool so identical codes sit together. Then run the standard subset recursion: at each node record the path, then loop over candidates from start.

The key rule: inside the loop, if `i > sta...


Submit Your Answer
Markdown supported