Generate Complete Outfits from Shopping Pins Within a Budget
Last updated: November 29, 2026
Quick Overview
Given shoppable Pins grouped by category (tops, shoes, bags) with prices, list outfits that pick exactly one item from every category with a total price at or under the budget, returning at most a fixed number of results.
0
0
0 solved
Given shoppable Pins grouped by category (tops, shoes, bags) with prices, list outfits that pick exactly one item from every category with a total price at or under the budget, returning at most a fixed number of results.
Shop the Look and shopping boards on Pinterest naturally lead to 'complete the outfit' features. The interviewer checks a clean backtracking template, meaningful pruning (sorted prices plus a lower bound on remaining spend), and a hard cap on output so the function cannot explode.
What the Interviewer Expects
- Writes a recursive backtracking function with explicit choose and unchoose
- Sorts items by price and breaks out of the loop once an item is too expensive
- Uses a suffix minimum to prune branches that cannot complete within budget
- Caps the number of results to bound runtime
- Explains worst-case exponential complexity honestly
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 return the k cheapest outfits overall instead of the first k found?
- How would you rank outfits by style compatibility instead of price?
- What if some categories are optional?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Exactly one item per category, total <= budget.
- Deterministic order: categories by name, items by (price, id).
- Return at most
limitoutfits. Any empty category means no outfit is possible....
High-Level Design
Process categories in a fixed order. At depth i we have spent some amount; we try each item of category i in price order. Two prunes: a precomputed suffix minimum tells us the cheapest way to finish, ...