A major concert is about to go on sale. Reservations succeed only within the seats that remain, and under no circumstances may more than the available inventory be sold. Complete the reserve(count) reservation logic. Note: when sales open, many reservation requests arrive at once β asynchronously within a single process.
This challenge has you build a concert seat reservation API in NestJS. Reservations succeed only within the seats that remain, and under no circumstances may more than the available inventory be sold. You complete the reserve(count) logic for the case where many requests arrive at once within a single process, using the in-memory inventory as the single source of truth.
This problem is about how an API should behave when many requests compete over the same inventory at the same time. For resources where many requests fight over the same number β seats, balances, points, coupons β code can look fine when handled one request at a time, yet the real test is the moment everything arrives at once. Verifying code like this means going beyond single-request checks: you fire more requests than the inventory all at once and confirm the sum of successful reservations never exceeds the initial inventory.