Reported September 2026
Instacarthash table

Product Total With the Cheapest Promotion

Reported by candidates from Instacart's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Instacart OA. Under 2s to a working solution.
Founder's read

The Instacart OA reported in September 2026 hides its whole difficulty in the spec. Product records like A|Apple|3|100, promotions that come in two flavors, and a rule that negative quantity or price records get skipped but processing continues. It's string parsing plus a hash map, then a min per record. Nothing exotic. The risk is misreading one rule and failing hidden tests with a clean-looking solution. If you blank on the parsing or the floor math, StealthCoder is the safety net running invisibly during the live OA.

The problem

Given product and promotion records, return the minimum total price in integer cents.
Each product record has the form sku|name|quantity|priceCents. Skip a product record exactly when quantity or priceCents is negative, and continue processing later records. Every other record contributes independently, including repeated SKUs.
Promotion records have either form:
sku|pct|p: charge floor(quantity * priceCents * (100 - p) / 100) cents for the full product record.
sku|bxyf|x|y: each complete group of x + y units contains y free units. The charged count is quantity - floor(quantity / (x + y)) * y.
A SKU has at most one promotion of each type. For every valid product record, choose the minimum of its regular price and every applicable promoted price. A product without a promotion uses its regular price.

Function
minimumProductTotal(products: String[], promotions: String[]) → long

Examples
Example 1
products = ["A|Apple|3|100","B|Bread|2|250","C|Bad|-1|900"]
promotions = ["A|pct|20","A|bxyf|2|1","B|pct|10"]
return = 650
For A, buy-two-get-one-free charges 200, cheaper than the 240 percentage price. B costs 450 after 10% off. The negative-quantity C record is skipped.
Example 2
products = ["X|Item|5|99","X|Again|2|99","Y|Free|0|500","Z|Skip|1|-5"]
promotions = ["X|bxyf|2|1","Y|pct|100"]
return = 594
The two X records are priced independently at 396 and 198. Zero quantity contributes zero, and the negative-price record is skipped.
Example 3
products = ["A|A|1|101","B|B|7|80","C|C|2|200"]
promotions = ["A|pct|33","B|bxyf|2|1"]
return = 867
The percentage price for A floors 67.67 to 67 cents. B charges five of seven units for 400, and unpromoted C costs 400.

Constraints
0 <= products.length <= 10^5 and 0 <= promotions.length <= 2 * 10^5.
Every record is syntactically valid, and string fields do not contain |.
For percentage promotions, 0 <= p <= 100.
For buy-x-get-y-free promotions, x and y are positive.
Every intermediate line price and the final answer fit in a signed 64-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Pattern: hash table. First pass over promotions, split on |, and store per SKU one percentage value and one bxyf pair (x, y). Since a SKU has at most one of each type, two maps or one small struct works. Second pass over products: skip if quantity or price is negative, compute regular = quantity * price, then take the min with the pct price floor(regular * (100 - p) / 100) and the bxyf price (quantity - (quantity / (x + y)) * y) * price. Sum into a long. Pitfalls: using float division for the percentage (use integer math), applying the promotion once per SKU instead of per record (repeated SKUs price independently), and treating a skipped record as a stop. Zero quantity is valid and contributes zero. If you freeze on the details under the clock, StealthCoder can hand you the clean version live.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Product Total With the Cheapest Promotion cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Instacart's OA.

Instacart reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Product Total With the Cheapest Promotion FAQ

How hard is the Instacart product total OA really?+

Easy to medium. There's no clever algorithm. It's parsing and careful arithmetic. Most failures come from missed rules like skipping negatives, pricing repeated SKUs separately, or flooring wrong, not from complexity.

What's the core trick?+

Preload promotions into hash maps keyed by SKU, then stream through products once. For each valid record, compute regular, percentage, and buy-x-get-y prices and add the minimum. That's O(n + m) time.

How do I avoid floating point errors on the percentage price?+

Use integer math only: quantity * priceCents * (100 - p) / 100 with integer division. All values are nonnegative, so integer division equals floor. Use a 64-bit type for the multiplication.

How should the buy-x-get-y-free formula be handled?+

Charged units equal quantity minus (quantity / (x + y)) * y, using integer division. Multiply charged units by priceCents. Check it against example 3: 7 units with x=2, y=1 gives 7 - 2 = 5 charged, so 400.

How do I prepare in 48 hours?+

Write a parser that splits on | and practice hash map lookups with small structs. Then hand-run all three examples, including the skipped records and zero quantity. Test edge cases: no promotions, empty products, 100 percent off, and repeated SKUs.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Instacart.

OA at Instacart?
Invisible during screen share
Get it