📣 黑五网一特惠|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 18
跳转到指定楼层
上一主题 下一主题
收起左侧

Belvedere Trading SDE NG 2024 OA 求米!!!!!

   
🔗
匿名用户-C87IP  2023-8-10 20:25:25 |倒序浏览

2024(4-6月) 码农类General 本科 全职@belvederetrading - 网上海投 - 技术电面  | 😐 Neutral 😣 Hard | Other | 应届毕业生

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

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

x
本帖最后由 匿名 于 2023-8-10 20:26 编辑

如果对你有帮助,真的求米!!!!不会消耗你的米,感谢感谢题目描述很多,3道全是实践题,最讨厌这种了

第一题:
Concert Ticket Exchange
编程挑战说明:
Concert tickets can be hard to come by, especially when going through the resale market. We would like to build our own concert ticket exchange system so that we can view available tickets in real-time. This system will listen to incoming ticket orders for a new concert venue, BT Arena. We'd like to build a system that listens to concert ticket orders and provides fans with this market information in the form of a price ladder.
Concert ticket orders arrive as a stream of events that can either add an order to our market data book or delete an order from our book. We also want to be able to delete all orders at given price level.
Add orders come with the following information:
Action - ADD
OrderId - unique identifier for order
Artist - concert performer, such as "TaylorSwift" or "Drake"
Price - price for the order
Quantity - positive quantity is a buy order and negative quantity is a sell order
Delete orders come with the following information:
Action - DEL
Artist - concert performer, such as "TaylorSwift" or "Drake"
OrderId - Unique identifier for the order to be deleted
Delete price levels come with the following information:
Action - DEL_PRICE
Artist - concert performer, such as "TaylorSwift" or "Drake"
Price - price level to be deleted
We'd like to keep track of these events so that fans can request a market view in the form of a price ladder. A price ladder is made up of n price levels for buy orders and sell orders. A price level consists of the Price, BuyQuantity, and SellQuantity. A price level will either have a non-zero BuyQuantity or SellQuantity, but not both. For buy orders, the best price is the highest price because that is the price a ticket holder would sell at. Conversely, the best price for sell orders is the lowest price. The streamed events will guarantee at least n price levels for both buys and sells.
输入:
Repeated number of order operations in the following format:
<ADD> <OrderId> <Artist> <Price> <Quantity>
<DEL> <OrderId> <Artist>
<DEL_PRICE> <Artist> <Price>
We can get orders for different artists in the same stream of operations. The last line of input will the artist and number of price levels that we would like to view in our ladder for both buy and sell orders.
<Artist> <NumberOfPriceLevels>
Example Input:
ADD 1 TaylorSwift 100 10
ADD 2 TaylorSwift 101 -10
ADD 3 TaylorSwift 99 5
ADD 4 TaylorSwift 102 -5
ADD 5 TaylorSwift 100 2
ADD 6 Drake 95 2
DEL 1 TaylorSwift
TaylorSwift 2
输出:
The price ladder should begin with the artist name and should be followed by a repeated list of levels.
<Artist>
<BuyQuantity> <Price> <SellQuantity>
The levels should be sorted by price in descending order and contain NumberOfPriceLevels for buy and sell orders. Levels with 0 BuyQuantity and 0 SellQuantity should not be printed.
Example Output:
TaylorSwift
0 102 5
0 101 10
2 100 0
5 99 0
测试 1
测试输入
下载测试 1 输入
ADD 1 TaylorSwift 100  10
ADD 2 TaylorSwift 101 -10
ADD 3 TaylorSwift 99   5
ADD 4 TaylorSwift 102 -5
ADD 5 TaylorSwift 100  2
DEL 1 TaylorSwift
TaylorSwift 2
预期输出
下载测试:1 项输出
TaylorSwift
0 102 5
0 101 10
2 100 0
5 99 0
测试 2
测试输入
下载测试 2 输入
ADD 1 TaylorSwift 100  10
ADD 2 TaylorSwift 101 -10
ADD 3 TaylorSwift 99   5
ADD 4 TaylorSwift 102 -5
ADD 5 TaylorSwift 98 2
ADD 6 TaylorSwift 99   5
DEL_PRICE TaylorSwift 100
TaylorSwift 1
预期输出
下载测试:2 项输出
TaylorSwift
0 101 10
10 99 0
完成下列的代码
import sys
import math
# Data classes
class AddOrder():
    def __init__(self, orderId, artist, price, quantity):
        self.orderId = int(orderId)
        self.artist = str(artist)
        self.price = float(price)
        self.quantity = float(quantity)
class ModifyOrder():
    def __init__(self, orderId, artist, price, quantity):
        self.orderId = int(orderId)
        self.artist = str(artist)
        self.price = float(price)
        self.quantity = float(quantity)
class DeleteOrder():
    def __init__(self, orderId, artist):
        self.orderId = int(orderId)
        self.artist = str(artist)
class DeletePriceLevel():
    def __init__(self, artist, price):
        self.artist = str(artist)        
        self.price = int(price)
# TODO(candidate): implementation below
class PriceLadder():
    def __init__(self):
        pass
    def AddOrder(self, order):
        # TODO(candidate): implement
        pass
    def DeleteOrder(self, delete):
        # TODO(candidate): implement
        pa
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
le_symbol>, <execute_or_pass>, <bundle_or_individual_stocks>, <total_price>
apx E B 100.0
spj E I 130.0
sspx E I 20.0
dpx E B 900.0
spdx P /* no arbitrage opportunity */
测试 1
测试输入
下载测试 1 输入
3 5
apx 99.5 3 aapl 4 amzn 3 aarp 4
spj 200.0 2 spy 3 swg 2
sspx 65 2 spy 1 aapl 1
aapl 10.5
amzn 12.0
aarp 5.0
spy 45.0
swg 33.5
预期输出
下载测试:1 项输出
apx E I 98.00
spj E B 200.00
sspx E I 55.50
测试 2
测试输入
下载测试 2 输入
2 4
adgb 5404.0 3 tadb 2 goog 2 meta 1
tadb 2520.0 2 bbby 5 hmny 4
goog 125.0
meta 114.0
bbby 225.0
hmny 350.75
预期输出
下载测试:2 项输出
adgb P
tadb E B 2520.00
测试 3
测试输入
下载测试 3 输入
2 4
adgb 5402.0 3 tadb 2 goog 2 meta 1
tadb 2530.0 2 bbby 5 hmny 4
goog 125.0
meta 114.0
bbby 225.0
预期输出
下载测试:3 项输出
adgb P
tadb P
完成下列代码
import sys
class Bundle:
    def __init__(self, name, price, components):
        self.name = name
        self.price = price
        self.components = components
class Stock:
    def __init__(self, name, price):
        self.name = name
        self.price = price
def PrintTrade(name, bundleOrStock, price):
    p = "{:.2f}".format(price)
    print("{} E {} {}".format(name, bundleOrStock, p))
def PrintNoTrade(name):
    print("{} P".format(name))
class MarketWatchPortfolio:
    def __init__(self, bundles, stocks):
        self.bundles = bundles
        self.stocks = stocks
    def ExecuteTrades(self):
        # TODO(candidate): fill out
        pass
def ParseInputs():
    bundles = list()
    stocks = dict()
    num_stocks = -1
    num_bundles = -1
    for line in sys.stdin:
        parsed = line.strip().split(' ')
        if num_bundles == -1 and num_stocks == -1:
            num_bundles = int(parsed[0])
            num_stocks = int(parsed[1])
            continue
        if num_bundles > 0:
            components = list()
            for i in range(3, len(parsed) - 1, 2):
                components.append((int(parsed[i + 1]), parsed[i]))
            bundles.append(Bundle(parsed[0], float(parsed[1]), components))
            num_bundles -= 1
            continue
        s = Stock(parsed[0], float(parsed[1]))
        stocks[parsed[0]] = s
    return MarketWatchPortfolio(bundles, stocks)
def main():
    portfolio = ParseInputs()
    portfolio.ExecuteTrades()
if __name__ == '__main__':
    main()

如果对你有帮助,真的求米!!!!不会消耗你的米,感谢感谢

评分

参与人数 28大米 +29 收起 理由
小亩_975f7f6 + 1 给你点个赞!
vgn2210 + 1 点个赞
harperzhu + 1 很有用的信息!
hoope + 1 赞一个
GuangyanLi + 1 感谢!

查看全部评分


上一篇:Cisco 思科 SDE2 Intern oa 2024,求米!!!!!!
下一篇:数学能行 SDE面经 - 诡异
推荐
JamesTKirk 2023-8-18 08:13:25 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
回复

使用道具 举报

地里匿名用户
推荐
匿名用户-6XBXK  2023-8-31 23:25:09
明明明明 发表于 2023-8-13 17:40
这个测试样例是不是有问题

没有问题的哦,注意审题~
回复

使用道具 举报

全局:
服了,等我真的要implement的时候已经堵了太多忘了哟我implement什么了
回复

使用道具 举报

🔗
iwantu 2023-8-11 00:06:00 | 只看该作者
全局:
地里看intern好像都是旧题,ng都是新题吗
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-G3Y0X  2023-8-11 00:37:42 来自APP
请问开摄像头了吗 谢谢
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-YB1YJ  2023-8-11 07:41:27 来自APP
这家是白嫖呀
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-YB1YJ  2023-8-11 07:41:52 来自APP
发错了,这家是白嫖吗
回复

使用道具 举报

全局:
iwantu 发表于 2023-08-10 09:06:00
地里看intern好像都是旧题,ng都是新题吗
应该是新的,我看了往年ng不是这个题
回复

使用道具 举报

全局:
匿名用户 发表于 2023-08-10 16:41:52
发错了,这家是白嫖吗
我也不知道哎,只知道不是秒发,4小时之后发的
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-XPWI9  2023-8-11 13:50:29
匿名用户 发表于 2023-8-10 09:37
请问开摄像头了吗 谢谢

不开摄像头
回复

使用道具 举报

🔗
果子梨 2023-8-11 13:58:43 | 只看该作者
全局:
谢谢楼主 好人一生平安
回复

使用道具 举报

全局:
匿名用户 发表于 2023-08-10 09:37:42
请问开摄像头了吗 谢谢
没有哦
zszsz
回复

使用道具 举报

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

本版积分规则

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