List Every Distinct Bundle From Items With Repeated SKUs
Last updated: November 29, 2026
Quick Overview
Given a list of SKUs that may contain duplicates, return every distinct sub-bundle (subset), including the empty bundle, with no duplicate bundles in the output.
Amazon
November 29, 20260
0
0 solved
Given a list of SKUs that may contain duplicates, return every distinct sub-bundle (subset), including the empty bundle, with no duplicate bundles in the output.
A phone-screen backtracking warm-up in Amazon's style, framed around enumerating bundle options for a promotion where the same SKU can appear twice. The interviewer checks the sort-and-skip technique for duplicates rather than deduplicating with a set afterwards.
What the Interviewer Expects
- Sorts first so equal SKUs are adjacent
- Skips a duplicate at the same recursion depth
- Includes the empty bundle
- States the 2^n output bound
- Copies the path when recording a result
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you enumerate only bundles of size exactly k?
- How would you count distinct bundles without listing them?
- How would you stream bundles lazily instead of building a list?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Return all distinct multisets drawn from the input, order of bundles irrelevant, each bundle listed once. Input up to around 10 to 15 items, since output is exponential....
High-Level Design
Standard subset backtracking: at each level pick the next item from index start onward. Duplicates arise when two equal SKUs are both tried as the same choice at the same depth. Sorting places t...