As reported: Target Engineer L4 onsite (2025, in person), round 2 (system design + problem solving): LLD of billing software for a vending machine.
Design the billing software of a vending machine: the customer selects a product, pays, and receives the product and any change; an operator restocks products and cash.
Cover the requirements, the classes and their relationships, the key methods, and how the machine behaves on edge cases.
Agree on scope first: payment methods (coins and notes, cards), whether the machine gives change, and what happens when it cannot.
Code runner format: two lines in LeetCode's design format: the method names and their arguments. The harness prints the list of return values (null for the constructor, restock and loadCash). Implement VendingMachine with this practice scope (amounts in cents; accepted coins and notes: 1, 2, 5, 10, 20, 50, 100, 200, 500):
restock(code, name, price, quantity)— a new slot, or more units in an existing one (its name and price stay).loadCash(denomination, count).select(code)—"busy: cancel first"while a product is selected,"invalid code","sold out", or"<name>: pay <price>".insert(denomination)—"returned <d>: select a product first"when nothing is selected,"returned <d>: not accepted"for other values,"balance <b>"while the balance is below the price. Once it reaches the price: the change (balance − price) is paid with the fewest coins from the cash box plus the coins just inserted →"dispensed <name>, change <coins>"; if no combination works →"cannot make change, refunded <coins>". Either way the machine is idle again.cancel()— returns the inserted coins ("none"if there are none) and goes idle.<coins>lists coins largest first joined by+("20+10","2+2+2"), or"none". The tests never have two different fewest-coin ways to pay the same change.sold(name)— units sold;cashCount(denomination)— coins of that value in the cash box.
Python uses snake_case (load_cash, cash_count); Go uses Constructor() and exported names (Restock, Insert, …).