Clarify percentage and buy-x-get-y pricing rules, then reason about the cheapest legal discount combination, quantity thresholds, interactions, and rounding.
Specify the Lowest Price Across Percentage and Buy-X-Get-Y Discounts
Company: Instacart
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Onsite
Design a price-calculation procedure that takes transaction records and available discounts, then returns the most favorable permitted price. Discounts include percentage reductions and buy-x-get-y offers.
### Constraints
The transaction schema, offer eligibility, stacking rules, repeated-use limits, free-item selection, and rounding policy are unspecified. Clarify them before claiming a unique minimum price. This is a conditional pricing-algorithm discussion, with no invented fixed policy or executable console contract.
### Clarifying Questions
- Does buy x get y mean y additional units are free, and can the offer repeat?
- Which items qualify, and which items become free if prices differ?
- Can percentage and quantity offers stack, and in what order?
- Is the best price chosen per line, per product, or for the whole transaction?
- At which stage are amounts rounded to the smallest currency unit?
```hint Define what makes two offers compatible
Choosing the cheapest option independently for each item is valid only when eligibility and usage constraints do not couple the choices.
```
### What a Strong Answer Covers
- Explicit pricing semantics and separation of eligibility from discount evaluation.
- A conditional algorithm that actually finds the optimum under its stated assumptions.
- Quantity boundaries, rounding, interactions, and validation of a reproducible result.
### Follow-up Questions
- What changes if a promotion can be used only once across the whole basket?
- How would you explain which offer produced the selected price?
Overview: Clarify percentage and buy-x-get-y pricing rules, then reason about the cheapest legal discount combination, quantity thresholds, interactions, and rounding.
Design a price-calculation procedure that takes transaction records and available discounts, then returns the most favorable permitted price. Discounts include percentage reductions and buy-x-get-y offers.
Constraints
The transaction schema, offer eligibility, stacking rules, repeated-use limits, free-item selection, and rounding policy are unspecified. Clarify them before claiming a unique minimum price. This is a conditional pricing-algorithm discussion, with no invented fixed policy or executable console contract.
Clarifying Questions Guidance
Does buy x get y mean y additional units are free, and can the offer repeat?
Which items qualify, and which items become free if prices differ?
Can percentage and quantity offers stack, and in what order?
Is the best price chosen per line, per product, or for the whole transaction?
At which stage are amounts rounded to the smallest currency unit?
What a Strong Answer Covers Guidance
Explicit pricing semantics and separation of eligibility from discount evaluation.
A conditional algorithm that actually finds the optimum under its stated assumptions.
Quantity boundaries, rounding, interactions, and validation of a reproducible result.
Follow-up Questions Guidance
What changes if a promotion can be used only once across the whole basket?
How would you explain which offer produced the selected price?