注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
有一点类似于robinhood的这道题。不过没有input orders, 需要自己写一个structure. 如果找到match的order, 交易成功,并且在order list中remove 相应的order.
Given a stream of incoming "buy" and "sell" orders (as lists of limit price, quantity, and side, like
["155", "3", "buy"]), determine the total quantity (or number of "shares") executed.
A "buy" order can be executed if there is a corresponding "sell" order with a price that is less than or
equal to the price of the "buy" order.
Similarly, a "sell" order can
// Prints help message to the console
// Returns a string
//
// Globals declared here will cause a compilation error,
// declare variables inside the function instead!
Order Book
Buys: ['100', '9', 'buy']
Sells: , ['200', '1', 'sell']
Total Shares: 5 + 3 + 1 = 9
|