Part 1: Register Receivables
Stripe in Brazil is obliged to register customer’s transactions for each merchant with the central bank as an aggregated unit per day. These are called receivables.
A receivable is identified by 3 identifiers:
- merchant_id (String): The id of the merchant on Stripe side.
- card_type (String): The type of the card used for the transaction (e.g. Visa).
- payout_date (String): String date of the funds available to the merchant by Stripe.
A payment transaction in Stripe API can be represented as the following object:
Transaction { string customer_id string merchant_id string payout_date string card_type int amount }Implement register_receivables function that takes a string in CSV format where each line represents a transaction and returns the registered aggregated receivables using the rules above.
Example input 1:
customer_id,merchant_id,payout_date,card_type,amount cust1,merchantA,2021-12-30,Visa,150 cust2,merchantA,2021-12-30,Visa,200 cust3,merchantB,2021-12-31,MasterCard,300 cust4,merchantA,2021-12-30,Visa,50Output 1:
id,card_type,payout_date,amount merchantA,Visa,2021-12-30,400 merchantB,MasterCard,2021-12-31,300Example input 2:
customer_id,merchant_id,payout_date,card_type,amount cust1,merchantA,2021-12-29,MasterCard,50 cust2,merchantA,2021-12-29,Visa,150 cust3,merchantB,2021-12-31,Visa,300 cust4,merchantB,2021-12-29,MasterCard,200Output 2:
id,card_type,payout_date,amount merchantA,MasterCard,2021-12-29,50 merchantA,Visa,2021-12-29,150 merchantB,Visa,2021-12-31,300 merchantB,MasterCard,2021-12-29,200
Part 2: Contracts and Updates
In Brazil, settlement times can take up to 30 days for domestic card transactions.
Merchants can sell their receivables to a financial institution in order to get funds earlier.Stripe is obliged to respect those contracts and update the registered receivables.
Each contract is mapped to one receivable using the same 3 identifiers as before:
- merchant_id
- card_type
- payout_date
In addition, merchants can sell part of their receivables and/or receive multiple contracts for the same receivable.
Safe assumptions:
- Contract amount will not exceed the receivable amount.
- If a receivable is sold fully, it should be returned as part of registered receivables with amount 0.
- Contracts will not have zero amounts.
Update the registered_receivables function implemented in Part 1 to reflect these new rules.
题目背景:
- 在巴西,Stripe 需要向央行登记每天的交易汇总信息(称为 receivables)。
- 每个 receivable 由商户 ID、卡类型和结算日期唯一标识。
- 输入是多条交易记录(CSV 格式),需要按规则聚合输出每日应收账款。
- 第二部分题目进一步引入 contracts(合同) 概念,要求更新 receivable 状态以反映部分或全部出售的情况。
考察点:
- 数据聚合与分组(group by 多键);
- CSV 解析与输出;
- 状态更新逻辑(部分出售、全额出售);
- 面向真实金融合规业务场景的建模与思维能力。
VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 Stripe、Google、Amazon、Citadel、SIG 等,提供实时语音助攻、远程陪练与面试节奏提醒,帮助大家在关键时刻不卡壳。
如果你也在准备 Stripe 或类似工程向公司,可以了解一下我们的定制助攻方案——从编程面到系统设计,全程护航上岸。