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
Coding & Algorithms
Software Engineer
Meesho
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

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
bitmask dynamic programming
set cover
reconstruction
combinatorial optimisation
recommendations
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
  • 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions