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
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

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
backtracking
duplicates handling
subsets
recursion
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 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 Problems
Sample 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...


Submit Your Answer
Markdown supported