Cheapest Product Bundle Covering Every Requested Outfit Category
Last updated: November 29, 2026
Quick Overview
A shopper wants a complete outfit covering a set of required categories (for example kurti, dupatta, palazzo), and each product covers one or more categories at a given price (sets and combos cover several). Return the minimum total price to cover every required category and the products chosen, or report that it is impossible.
Meesho
November 29, 20260
0
0 solved
A shopper wants a complete outfit covering a set of required categories (for example kurti, dupatta, palazzo), and each product covers one or more categories at a given price (sets and combos cover several). Return the minimum total price to cover every required category and the products chosen, or report that it is impossible.
Combo listings such as kurti sets compete with buying pieces separately on Meesho, and a complete-the-look feature has to find the cheapest way to cover an outfit. The interviewer expects you to recognise weighted set cover, notice the small number of categories, and write a bitmask DP with reconstruction.
What the Interviewer Expects
- Recognises the problem as weighted set cover, NP-hard in general
- Exploits a small category count with a bitmask DP
- Ignores categories outside the request when building masks
- Reconstructs the chosen products, not just the cost
- Handles the impossible case and the empty request
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
- Each product has a stock limit and a supplier. Add a constraint of at most two suppliers to cut shipping.
- What if the shopper has a budget and wants the best-rated bundle within it?
- How would you serve this in under 50 ms when each category has 10,000 candidates?
- Why is a greedy cheapest-per-category approach wrong? Give a counterexample.
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: required, a list of k categories (k up to about 15), and products, a list of (product_id, price, categories). Output: (min_price, sorted product ids) or (None, []) if some category is...
High-Level Design
Map each required category to a bit. Each product becomes a mask of the required categories it covers (others are irrelevant). dp[mask] is the cheapest cost to cover exactly the categories in mask...