Fill a Multi-Item Order From the Fewest Fulfillment Centers
Last updated: November 29, 2026
Quick Overview
Given an order (SKU to quantity) and a set of fulfillment centers, each with a per-shipment cost and per-SKU stock, choose the smallest set of centers whose combined stock can fill the order, breaking ties by lowest total shipment cost, and return an allocation. Return None if the order cannot be filled.
Fanatics
November 29, 20260
0
0 solved
Given an order (SKU to quantity) and a set of fulfillment centers, each with a per-shipment cost and per-SKU stock, choose the smallest set of centers whose combined stock can fill the order, breaking ties by lowest total shipment cost, and return an allocation. Return None if the order cannot be filled.
Fanatics ships from several fulfillment centers and partner sites, and every extra box means more shipping cost and a worse fan experience for a single order. This onsite problem checks whether you recognize the set-cover flavor, pick an exact method that fits realistic sizes, and still produce a concrete allocation.
What the Interviewer Expects
- Recognize the problem is NP-hard in general (set cover with multiplicities)
- Exploit that the number of candidate centers per order is small
- Build subset stock sums incrementally from a smaller subset
- Apply the lexicographic objective (count, then cost)
- Produce a valid allocation from the chosen set
- Prune centers that cannot contribute
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
- With 60 candidate centers, what heuristic or ILP formulation would you use instead?
- How would you add per-unit pick costs and split-shipment delivery promises?
- Stock changes while you compute. How does this interact with inventory reservation?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Order: dict of SKU to quantity. Centers: (name, cost_cents, stock_dict). Quantities of one SKU may be split across centers. Minimize number of centers, then total fixed cost. Typical candidate set a...
High-Level Design
Drop centers holding none of the order's SKUs. For F useful centers, enumerate all masks. The stock vector of a mask equals that of the mask without its lowest bit plus that center's vector, so ...