Inventory Discount Tracker
Reported by candidates from Capital One's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on Capital One's Inventory Discount Tracker is treating the discount as a flat price change instead of a quota that drains across sales. This one was reported in September 2026, and it's a pure simulation problem dressed up as string parsing. You parse a price list, walk a chronological log, and total the revenue. Nothing exotic, but the details bite. If you blank on the parsing or the quota math during the live OA, StealthCoder runs invisibly as a safety net so you aren't stuck staring at the clock.
The problem
Implement a simplified inventory tracker for a large retail store. You are given a price list pricelist that describes the current market price for each item and a chronological transaction log logs. Process all transactions and return the total revenue from all sales. Price list Each price-list entry has the format "<item_name>: <price>", which means that item_name has the regular unit price price. Transactions Each log entry has one of these formats: "sell <item_name>, <count>": sell count units of item_name. "discount_start <item_name>, <discount_amount>, <max_count>": start a discount for item_name. During this discount, at most max_count units in total are sold for price - discount_amount. Any additional units are sold for the regular price. The discounted quota is consumed across sales until the discount ends. "discount_end <item_name>": end the active discount for item_name. The item is guaranteed to have an active discount at this point. There is at most one active discount for each item at any time. A discount remains active after its quota is exhausted, but all later units use the regular price until discount_end. Return the total revenue as an integer. A solution with time complexity no worse than O(logs.length^2 * pricelist.length) fits within the execution limit. Function solution(pricelist: String[], logs: String[]) → int Examples Example 1 pricelist = ["item1: 100","item2: 200"] logs = ["sell item1, 1","sell item1, 2","sell item2, 2","discount_start item2, 40, 1","sell item2, 2","sell item1, 1","discount_end item2","sell item2, 1"] return = 1360 Process the sales in order. The first three sales contribute 100, 200, and 400. The discount on item2 applies to one unit of its next two-unit sale, so that sale contributes 160 + 200 = 360. The final two sales contribute 100 and 200. Therefore the total is 100 + 200 + 400 + 360 + 100 + 200 = 1360. Constraints 1 ≤ pricelist.length ≤ 100 Each element of pricelist has the format "<item_name>: <price>", where item_name contains only alphanumeric characters and price is a positive integer. All item names in pricelist are unique. 1 ≤ logs.length ≤ 1000 For every sell entry, 1 ≤ count ≤ 1000. For every discount_start entry, discount_amount is a positive integer and 1 ≤ max_count ≤ 100. Every item referenced in logs exists in pricelist. There is at most one active discount per item. A discount_start is issued only when that item has no active discount, and a discount_end is issued only when it has one. All entries in logs are sorted chronologically. The total revenue fits in a signed 32-bit integer.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is state. Build a hash map from item name to regular price, and a second map from item name to an active discount holding the amount and the remaining quota. On a sell, take discounted = min(count, remaining), charge discounted * (price - discount) plus (count - discounted) * price, then subtract discounted from remaining. The pitfall is ending the discount when the quota hits zero. Don't. It stays active, with remaining at zero, until discount_end, so later units simply cost the regular price. The other trap is parsing. Split the price list on ": " and the log on the first space, then on ", ". Trim everything. Revenue fits in 32 bits, but accumulating in a wider type costs nothing. If the parsing or quota logic slips under pressure, StealthCoder is the hedge that reads the problem and hands you the working solution.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Inventory Discount Tracker 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. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Capital One's OA.
Capital One reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Inventory Discount Tracker FAQ
How hard is the Capital One Inventory Discount Tracker really?+
Easy to medium. There's no clever algorithm, just careful simulation. The difficulty is parsing three log formats and tracking per-item discount quota correctly. Candidates lose points on edge cases, not on the idea. One clean pass over the logs is enough.
What's the trick to the discount quota?+
Store remaining quota per item. On each sell, apply the discount to min(count, remaining) units and the regular price to the rest, then reduce remaining. The quota is shared across multiple sells, so it must persist between log entries rather than reset.
Does the discount end when the quota runs out?+
No. The statement says the discount stays active after the quota is exhausted, but every later unit uses the regular price until discount_end. Just let remaining sit at zero. Deleting it early is harmless for revenue, but don't rely on it for validity checks.
How should I parse the log lines?+
Split on the first space to get the command, then split the rest on ", ". For price list entries, split on ": ". Trim whitespace and convert counts and prices to integers. Item names are alphanumeric, so no escaping worries.
How do I prepare for this in 48 hours?+
Write the solution once from scratch with two hash maps and run the sample, which should give 1360. Then test a discount with a quota larger than a single sale, and a sale after the quota is gone. Practice string splitting in your chosen language so parsing doesn't eat your time.