回复: 8
跳转到指定楼层
上一主题 下一主题
收起左侧

Akuna Shanghai C++ OA

全局:

2017(10-12月) 码农类General 硕士 全职@akunacapital - 网上海投 - 在线笔试  | | Other | 在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
Write a Matching Engine

you're going to write an exchange order matching engine.

The input is from stdin, each line file has several columns separated by one space.

The first column specifies the operation to be done. Our supported operations are:

BUY
SELL
CANCEL
MODIFY
PRINT

If the first column is BUY or SELL, then this line has five columns in total:
The second column is the order type, it's either IOC or GFD.
The third column is the price you want to buy or sell, it's an integer.
The fourth column shows the quantity of that buy or sell, it's an integer. Both the price and quantity are positive numbers.
The fifth column is the order id, it can be arbitrary words.

If the first column is CANCEL, then this line has two columns in total:
The second column is the order id, it means that order needs to be deleted, it can't be traded anymore.
If that order id doesn't exist, just do nothing.

If the first column is MODIFY, then this line has five columns in total:
The second column is the order id, it means that order needs to be modified.
The third column is either BUY or SELL.
The fourth column is the new price of that order.
The fifth column is the new quantity of that order.

If that order id doesn't exist, just do nothing.

(Note: that we can't modify an IOC order type, as we'll mention later.)
MODIFY is a powerful operation, e.g
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
er1 1000 10 order3 900 10

We guarantee that:
order id is unique.

Example 1:
BUY GFD 1000 10 order1
PRINT

The output of above would be:
SELL:
BUY:
1000 10

Example 2:
BUY GFD 1000 10 order1
BUY GFD 1000 20 order2
PRINT

The output of above would be:
SELL:
BUY:
1000 30

Example 3:
BUY GFD 1000 10 order1
BUY GFD 1001 20 order2
PRINT

The output of above would be:
SELL:
BUY:
1001 20
1000 10

Example 4:
BUY GFD 1000 10 order1
SELL GFD 900 20 order2
PRINT

The output of above would be:
TRADE order1 1000 10 order2 900 10
SELL:
900 10
BUY:

Any input with price <= 0 or quantity <= 0 or empty order id is invalid. Should be ignored by the application.

评分

参与人数 3大米 +15 收起 理由
nyjahchill + 5 很有用的信息!
lulu_0386 + 5 给你点个赞!
xxmxj + 5 很有用的信息!

查看全部评分


上一篇:Withdraw 面试!被小黑屋了,操!
下一篇:cisco meraki
🔗
lbx883 2017-11-27 04:12:56 | 只看该作者
本楼:
全局:
关注一下
回复

使用道具 举报

🔗
Garcia_0 2018-3-25 12:46:42 | 只看该作者
全局:
楼主test case都过了没
这题描述里面说匹配的时候时间前的优先,例子里面却又是先优先Price,再优先时间。。。
然后我写了个Price-Time的,5个testcase 不过
回复

使用道具 举报

🔗
 楼主| lixin832500 2018-3-25 12:57:45 | 只看该作者
全局:
Garcia_0 发表于 2018-3-25 12:46
楼主test case都过了没
这题描述里面说匹配的时候时间前的优先,例子里面却又是先优先Price,再优先时间。 ...

没时间做,也没打算去,withdraw了
回复

使用道具 举报

🔗
nochoice 2018-4-3 14:14:20 | 只看该作者
全局:
Garcia_0 发表于 2018-3-25 12:46
楼主test case都过了没
这题描述里面说匹配的时候时间前的优先,例子里面却又是先优先Price,再优先时间。 ...

你拿到onsite面试了吗?
回复

使用道具 举报

🔗
Garcia_0 2018-4-24 16:35:28 | 只看该作者
全局:
nochoice 发表于 2018-4-3 14:14
你拿到onsite面试了吗?

没有/(ㄒoㄒ)/~~
回复

使用道具 举报

🔗
xingwuzheng 2018-5-2 01:59:49 | 只看该作者
全局:
最近我也收到akuna的oa了。因为积分不够,每天上来看看有没有人发不带权限的。哭/

希望楼主好运。offer多多
回复

使用道具 举报

🔗
maanguo27 2018-11-24 09:25:48 | 只看该作者
全局:
Garcia_0 发表于 2018-3-25 12:46
楼主test case都过了没
这题描述里面说匹配的时候时间前的优先,例子里面却又是先优先Price,再优先时间。 ...

我也是五个case不过。。。实在想不通啊 你最后提交也是5个没过提交的吗 感觉还是有什么变态的corner case
回复

使用道具 举报

🔗
tinatinaliu 2018-12-1 09:48:44 | 只看该作者
全局:
maanguo27 发表于 2018-11-24 09:25
我也是五个case不过。。。实在想不通啊 你最后提交也是5个没过提交的吗 感觉还是有什么变态的corner case

可以贴代码一起分析下么, 感觉没看懂题哇。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表