Shortest Conveyor Window Containing Every Item of an Order
Last updated: November 29, 2026
Quick Overview
Items pass a picker on a conveyor in a known sequence of SKU letters. Given an order listing required SKUs (with multiplicity), return the shortest contiguous window of the conveyor that contains all required items, or an empty string if none exists.
Amazon
November 29, 20260
0
0 solved
Items pass a picker on a conveyor in a known sequence of SKU letters. Given an order listing required SKUs (with multiplicity), return the shortest contiguous window of the conveyor that contains all required items, or an empty string if none exists.
A minimum window substring problem in Amazon's fulfillment framing. The interviewer checks for a sliding window with a 'formed' counter so that validity is checked in O(1), correct multiplicity handling, and tight shrinking.
What the Interviewer Expects
- Count required items with multiplicity
- Expand right until all requirements are met
- Shrink left while still valid, recording the best
- Track how many requirement counts are satisfied for O(1) checks
- Handle no-solution and empty order
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 do this when items stream in and you need the latest valid window?
- What if the order items must appear in sequence (subsequence window)?
- How would you handle a huge alphabet of SKU strings?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Conveyor string s and order string t, both may be empty. Return the substring; ties resolved by leftmost. Empty t returns ''....
High-Level Design
Let need count t. missing is the total number of required units still not covered (starts at len(t)). Move right: if need[ch] > 0 the char covers a missing unit, decrement missing; always decrem...