Back to problems

Calculate Inventory Purchases with Buy-X-Get-Y-Free Coupons

Algorithm · Instacart · Medium

You manage a warehouse with a fixed stock of items. Each item record is an array of three strings: name, stock, and unitPrice. The stock is a non‑negative integer value, and the price is a decimal string with exactly two digits after the point, like "0.45" or "12.00". Names are unique ASCII identifiers. Implement a function that computes the total amount a customer must pay when they request quantity units of item, possibly under a “buy X get Y free” coupon. The quantity…

Checking your access…