Company: Amazon_12june
Difficulty: medium
Promo Code Validator A checkout service runs every promo code through a chain of checks: does the code exist, has it expired, is the cart large enough, has the customer already used it too often, and does it apply to what is in the cart. The order of those checks is part of the contract. An expired code must never be reported as a category mismatch — showing the wrong reason wastes the customer's time and destroys trust in the checkout. You are given a promo catalogue, a log of past redemptions and a batch of checkout requests. For each request, report whether the code may be applied, and if not, the first rule it broke. When it may be applied, report the discount in cents. Input Format The whole input arrives on standard input as three labelled sections, always in this order: === data/promos.json === <one JSON document> === data/usage.jsonl === <zero or more JSON objects, one per line> === data/requests.jsonl === <one or more JSON objects, one per line> Each header l