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.

Pinterest
Coding & Algorithms
Software Engineer
Pinterest
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

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
backtracking
pruning
combinatorics
shopping
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 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 Problems
Sample Answer
Requirements
  • Exactly one item per category, total <= budget.
  • Deterministic order: categories by name, items by (price, id).
  • Return at most limit outfits. 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, ...


Submit Your Answer
Markdown supported