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

求米求米🙏stripe 27-27New Grad OA轮 文字版 包含部分test case

🔗
匿名用户-VSXFT  7 天前 |倒序浏览

2026(10-12月) 码农类General 本科 全职@stripe - 网上海投 - 技术电面  | 😐 Neutral 😣 Hard | Other | 在职跳槽

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

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

x
已从图片版整理成文字版 包含部分test case 方便大家准备!

Split Tender
Many of Stripe's merchants rely on Stripe Terminal to accept in-person payments at the point of sale. In physical retail, it's common for a customer to cover a purchase with multiple payment methods. For example, they might cover a $100 purchase with a $40 gift card combined with a $60 credit card. This is called a split-tender transaction, and supporting it is a key requirement for retail merchants on Terminal.
For this multi-part question, we will be writing a system to process split-tender payments. When a transaction occurs, the system first deducts from the customer's available gift card balance, then charges the remaining balance to the customer's credit card. Given a chronological stream of payment events, your task is to calculate the correct credit card charge for each transaction. The question is broken down into four parts, each introducing a new event type: gift card expiration, regional credit card surcharges, and complex refund logic.
Function Description
Complete the function
  1. process_events
复制代码
in the editor below.
Function Parameters
  1. string events[n]
复制代码
: Lines for each event in chronological order. Lines have a format defined by one of three schemas:

    1. timestamp,ADD_GIFTCARD,customer_id,card_id,amount,valid_before
    复制代码
    1. timestamp,CHARGE,charge_id,customer_id,amount,zip_code
    复制代码
    1. timestamp,REFUND,charge_id,refund_amount
    复制代码
  1. string surcharge_rates[m]
复制代码
: A list of non-overlapping ZIP code ranges mapped to a surcharge percentage in the format
  1. start_zip-end_zip:rate
复制代码
, where start and end are inclusive.
Example:
  1. 90000-99999:0.05
复制代码
(representing 5%).
General Constraints and Assumptions

  • Events are in chronological order by timestamp.
  • All event lines are well-formed.
    1. charge_id
    复制代码
    values are unique across
    1. CHARGE
    复制代码
    events.
    1. REFUND
    复制代码
    events always reference a prior
    1. CHARGE
    复制代码
    event.
  • Each
    1. charge_id
    复制代码
    will receive at most one
    1. REFUND
    复制代码
    event.
    1. card_id
    复制代码
    values from
    1. ADD_GIFTCARD
    复制代码
    events are unique.
    1. surcharge_rates
    复制代码
    contains non-overlapping, valid ZIP code ranges.
    1. zip_code
    复制代码
    values are five-digit numeric strings.
Monetary Representation and Pre
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
d for the referenced
  1. charge_id
复制代码
, including surcharge.
  • Store credit second: If
    1. refund_amount
    复制代码
    exceeds the amount refundable to the credit card, refund the remaining amount as store credit by creating a new gift card for the original customer. The new
    1. card_id
    复制代码
    must be formatted as
    1. REFUND_{charge_id}
    复制代码
    . This gift card has no expiration date.Refund-created gift cards participate in future
    1. CHARGE
    复制代码
    events like any other gift card. Refund-created gift cards never expire. When choosing gift cards for a future charge, non-expiring gift cards are used after all valid gift cards with finite expiration timestamps.
    Output Format for
    1. REFUND
    复制代码
    : Return a flat string containing the amount refunded to the credit card and the amount refunded to the store credit gift card, separated by a single comma:
    1. CC_REFUND,GC_REFUND
    复制代码
    Example Input
    1. events = [
    2.     "1,ADD_GIFTCARD,cust1,gc1,5000,10",
    3.     "2,CHARGE,chg1,cust1,15000,90210",
    4.     "3,REFUND,chg1,12000"
    5. ]
    6. surcharge_rates = [
    7.     "90000-99999:0.05"
    8. ]
    复制代码
    Example Output
    1. [
    2.     "",
    3.     "10500,gc1:5000",
    4.     "10500,1500"  # CC_REFUND, GC_REFUND
    5. ]
    复制代码
    Appendix: Additional Test Cases
    The following test cases were shown in subsequent debugging screenshots. These are separate from the original problem's four example sections.
    Test Case 13
    Input:
    1. events = [
    2.     "1,ADD_GIFTCARD,cust_1,gc_1,5000,10",
    3.     "2,CHARGE,chg_1,cust_1,15000,90210",
    4.     "3,REFUND,chg_1,12000"
    5. ]
    6. surcharge_rates = ["90000-99999:0.05"]
    复制代码
    Expected output:
    1. ["", "10500,gc_1:5000", "10500,1500"]
    复制代码
    Test Case 16
    Input:
    1. events = [
    2.     "1,ADD_GIFTCARD,cust_1,gc_1,10000,10",
    3.     "2,CHARGE,chg_1,cust_1,20000,15000",
    4.     "3,REFUND,chg_1,21000",
    5.     "15,CHARGE,chg_2,cust_1,5000,15000",
    6.     "16,ADD_GIFTCARD,cust_1,gc_2,3000,20",
    7.     "17,CHARGE,chg_3,cust_1,9000,15000"
    8. ]
    9. surcharge_rates = ["10000-20000:0.10"]
    复制代码
    Expected output:
    1. [
    2.     "",
    3.     "11000,gc_1:10000",
    4.     "11000,10000",
    5.     "0,REFUND_chg_1:5000",
    6.     "",
    7.     "1100,REFUND_chg_1:5000,gc_2:3000"
    8. ]
    复制代码
    新人求米求米求米求米看面经啦 大感谢!
  • 评分

    参与人数 1大米 +11 收起 理由
    匿名用户-FHXH8 + 11 感谢分享!

    查看全部评分


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

    本版积分规则

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