Object-Oriented Programming · Coinbase · Medium
Approach: Hash Map of Orders + Running State Counters The natural way to identify an order is by its unique orderId, so a hash map from orderId to the order record gives direct access for GET, PAUSE, RESUME, and CANCEL. The only summary query is COUNT , which asks for a total that changes only when one of the mutating commands succeeds. Instead of recomputing totals by scanning all orders, maintain three counters — one each for LIVE, PAUSED, and CANCELLED. Every successful…
Checking your access…