Check a Multi-Brand Wholesale Cart Against Brand Order Minimums

Last updated: November 29, 2026

Quick Overview

Given a retailer's cart of line items (brand, unit wholesale price in cents, quantity) and a map of each brand's minimum order amount, return how far below its minimum each brand in the cart is. Brands that meet their minimum should not appear in the result.

Faire
Coding & Algorithms
Software Engineer
Faire
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a retailer's cart of line items (brand, unit wholesale price in cents, quantity) and a map of each brand's minimum order amount, return how far below its minimum each brand in the cart is. Brands that meet their minimum should not appear in the result.

On a wholesale marketplace every brand sets its own opening and reorder minimum, and checkout is blocked until each brand's subtotal clears it. This warm-up checks that you can group and aggregate cleanly, handle money as integers, and think about the product message the retailer sees.

What the Interviewer Expects
  • Group line items by brand and sum price times quantity
  • Use integer cents rather than floats for money
  • Treat a brand with no configured minimum as having a minimum of zero
  • Return only brands that are short, with the shortfall amount
  • State linear time and space in the number of line items
Key Topics to Cover
hash map aggregation
money as integer cents
group by
input validation
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 handle a brand that has a different minimum for opening orders versus reorders?
  • If minimums are defined in the brand's currency and the cart is in the retailer's currency, where does conversion happen?
  • How would you suggest products that close the gap for a short brand?
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: cart, a list of dicts with brand_id, unit_price_cents, quantity; and minimums, a dict from brand_id to minimum cents. Output: dict from brand_id to cents still needed. Clarify: ca...

High-Level Design

One pass to build per-brand subtotals in a hash map, then one pass over the brands present in the cart comparing each subtotal to its minimum. Only brands that actually appear in the cart matter, sinc...


Submit Your Answer
Markdown supported

Related Questions