Robinhood 电面

avatar 71729
xtaochina
2309
1
Robinhood 电面

1. bad transfer : 加锁 + email call function 已到后面去。
2. Take in a stream of orders (as lists of limit price, quantity, and side, like ["155", "3", "buy"]) and return the total number of executed shares.

Rules
- An incoming buy is compatible with a standing sell if the buy's price is >= the sell's price. Similarly, an incoming sell is compatible with a standing buy if the sell's price <= the buy's price.
- An incoming order will execute as many shares as possible against the best compatible order, if there is one (by "best" we mean most favorable to the incoming order).
- Any remaining shares will continue executing against the best compatible order, if there is one. If there are shares of the incoming order remaining and no compatible standing orders, the incoming order becomes a standing order.

Example input:
Stream of orders
("150", "10", "buy"), ("165", "7", "sell"), ("168", "3", "buy"), ("155", "5", "sell"), ("166", "8", "buy")

建一个Order 的class 用两个PriorityQueue match 解决,最后还需要跑test case.

一个小时候通知 not move forward, 不知道挂在哪里了。
  • 2
1条回复