Thread-safe Stock Buy/Sell API Preventing Oversell

Implement two functions buy(symbol, qty) and sell(symbol, qty) to maintain stock positions, and ensure that under concurrent multi-threaded calls the system never oversells.

Requirements

-...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: