注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
本帖最后由 匿名 于 2023-8-16 17:24 编辑
共22题,算法题如下
17. Trading Platform
A quantitative trading firm seeks to create a tool for querying the net profit/loss of the firm at any given time. The tool processes a list of events, each of which can be classified into one of four categories:
1. BUY stock quantity: Signifies the purchase of quantity> shares of stock <stock at the market price.
2. SELL stock quantity: Indicates the sale of <quantity> shares of stock stock> at the market price.
3. CHANGE stock price: Signifies a change in the market price of stock by <price> amount, which can be either positive or negative.
4. QUERY: Represents a query for the net profit/loss from the start of trading to the present.
The tool should return a list of numbers corresponding to each QUERY event.
Example
For instanc3">Complete the function getToca/Efficiency in the editor below.
getTotalEfficiency has the following parameter:
int sklial: the skills of each candidate
Returns
long int: the sum of the efficiencies if it is possible to form the teams, or -1 otherwise
Constraints
• 1 <=n<= 10^5
• 1<= skill[I] <=10^5
• n is even.
It is guaranteed that the answer is unique. |