Skip to main content
All Questions

Process a stream of trades and price updates and, on request, report the trade on an instrument with the largest loss per lot.

Unlock detailed company stats for this questionUpgrade
Process a stream of N instructions: TRADE (tradeId, instrument, buy/sell, price, volume), PRICE (instrument, new fair value) and WORST_TRADE (instrument). For a WORST_TRADE query output the id of the trade on that instrument with the largest loss per lot, valuing each trade against the latest price update; break ties by the most recent trade and print NO BAD TRADES if no trade is losing. Implement a class with ProcessTrade, ProcessPriceUpdate and OutputWorstTrade; N and the ids/prices/volumes go up to 10^6.

Community answers

No answers contributed by the community yet.

Related courses

Course

Behavioral Interviews: A Practical Guide for Engineers

Get offers at the level you deserve. Prep for senior+ behavioral interviews at FAANG and Tier-1 companies. Made with staff and principal engineers from Meta, Netflix, Google, and more. Avoid downleveling, elevate past projects, and stop sounding like a robot.

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.