Fewest Parcels to Ship an Order Across Fulfillment Centers

Last updated: November 29, 2026

Quick Overview

An order contains n distinct SKUs (n up to about 16), and each fulfillment center stocks some subset of them with a fixed per-parcel shipping cost. Choose fulfillment centers so every SKU is shipped, minimising first the number of parcels and then total shipping cost, and return which center ships which SKU.

Coupang
Coding & Algorithms
Software Engineer
Coupang
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


An order contains n distinct SKUs (n up to about 16), and each fulfillment center stocks some subset of them with a fixed per-parcel shipping cost. Choose fulfillment centers so every SKU is shipped, minimising first the number of parcels and then total shipping cost, and return which center ships which SKU.

Split shipments cost Coupang money and annoy customers who wanted one Rocket box, so order routing tries hard to fulfil from as few centers as possible. The problem is set cover, which is NP-hard in general, so the interviewer checks that you notice the small n and use a bitmask DP, then discuss what production would do at larger scale.

What the Interviewer Expects
  • Identify the problem as weighted set cover and say why greedy is not exact
  • Encode SKUs as bits and each center's coverage as a mask
  • DP over masks with a lexicographic (parcels, cost) objective
  • Argue why ascending mask order is a valid processing order
  • Reconstruct the assignment with parent pointers
  • Report O(2^n * m) and when it stops being feasible
Key Topics to Cover
Bitmask DP
Set cover
Lexicographic objectives
Path reconstruction
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 add inventory quantities greater than one?
  • Centers have different promised delivery dates; how do you trade parcels against arrival time?
  • What heuristic would you use for a 60 item bulk order?
  • How do you avoid every order draining the same well-stocked center?
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: order_items (list of SKUs, each quantity 1), fc_stock[fc] (set of SKUs) and ship_cost[fc]. Output: (parcels, cost, plan) with plan[fc] listing SKUs, or None if some SKU is stocked n...

High-Level Design

Map SKU i to bit i. Each center becomes (fc, cover_mask, cost); centers with no overlap are dropped. best[mask] is the best (parcels, cost) to cover exactly the SKUs in mask. From any reac...


Submit Your Answer
Markdown supported

Related Questions