Stripe logo

Stripe Hard Interview Questions

14 hard-level practice questions for Stripe technical interviews

Stripe software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Hard Verified Question #1

1. Filter Roles


Category: Tree coding problem
You are building a role-based access control (RBAC) system for a multi-tenant platform. The system manages user roles across a hierarchical account...
Input: List
Output: Array
Want to practise this one?
Create a free account to open the full question and practise Stripe questions with AI.
Sign up free
coding Hard Verified Question #2

2. Rate Limiter


Category: Sliding window coding problem
Design a rate limiter that tracks API requests per client and enforces limits using a sliding time window. Your system must support: - hit(key,...
Input: Given input
Output:** Computed result
coding Hard Verified Question #3

3. Email Subscriptions


Category: String coding problem
Design a subscription management system that tracks user subscriptions and sends automated emails at specific lifecycle events. Email Types: -...
Input: List
Output: Computed result
coding Hard Verified Question #4

4. [Bug Squash] Mako Template Engine


Category: Tree coding problem
In this bug squash round, you will find and fix errors in a Python template library. You will receive a link to a GitHub folder containing a version...
Input: List
Output: Printed output
coding Hard Verified Question #5

5. [Bug Squash] Moshi JSON Library


Category: String coding problem
In this bug squash round, you will find and fix mistakes in a Java library called Moshi. You will receive a link to a GitHub folder containing a...
Input: String
Output: Computed result
coding Hard Verified Question #6

6. Data Center Load Scorer


Category: Graph coding problem
A data center operations team monitors server energy usage to optimize resource allocation. You receive a daily dataset of all incoming requests to...
Input: Graph (nodes and edges)
Output: Array
coding Hard Verified Question #7

7. Wallet Transaction Ledger


Category: String coding problem
A fintech platform processes streams of wallet transactions and needs to consolidate them into account summaries. Each transaction is logged as a...
Input: List
Output: Computed result
coding Hard Verified Question #8

8. Employee Record Matcher


Category: Array coding problem
A data-quality team needs to detect duplicate or near-duplicate employee records in a large HR dataset. Each record is a row in a 2D string array...
Input: Array
Output: Array
coding Hard Verified Question #9

9. Candidate Tech Stack Filter


Category: String coding problem
A hiring platform screens candidates by comparing their declared technology stack against a job's required skills. A candidate submits a...
Input: Array of strings
Output: Array
coding Hard Verified Question #10

10. Subscriber Notification Planner


Category: Trie-based coding problem
A subscription service sends automated notifications to subscribers based on their subscription window. You are given a list of subscriber records...
Input: List
Output: Array
coding Hard heap #1

1. [Heap and Hash Map] — Reconcile payments against a changing invoice book


Background
Stripe Billing needs to associate incoming payments with outstanding invoices belonging to the correct merchant and currency. Candidate reports describe a Stripe interview task that matches by invoice ID first, then by amount, breaking ties by earliest due date. This adaptation adds invoice updates and cancellations to test efficient reconciliation against changing data; these extensions are not claimed to be the original interview prompt.
Problem statement
Implement a reconciliation engine that processes an ordered list of events. An invoice is active from the time it is opened until it is canceled or matched to a payment. Process each event completely before processing the next one.
Events have the following schemas:
  • OPEN: {"type":"OPEN","invoice_id":str,"merchant_id":str,"currency":str,"amount":int,"due_day":int}. Create an active invoice. Invoice IDs are globally unique and are never reused.

  • UPDATE: {"type":"UPDATE","invoice_id":str,"amount":int,"due_day":int}. Replace both the amount and due day of an active invoice. Its merchant and currency do not change. Ignore the event if the invoice is unknown or inactive.

  • CANCEL: {"type":"CANCEL","invoice_id":str}. Deactivate the specified invoice. Ignore the event if the invoice is unknown or inactive.

  • PAY: {"type":"PAY","merchant_id":str,"currency":str,"amount":int,"invoice_id":str|null}. Match this payment using the rules below.


For each PAY event:
1. An invoice is eligible only if it is active and its merchant, currency, and amount all exactly equal those of the payment.
2. If the supplied non-null invoice ID identifies an eligible invoice, select it, regardless of its due day.
3. Otherwise, select the eligible invoice with the smallest due day. Break equal-due-day ties using the lexicographically smallest invoice ID.
4. If an invoice is selected, deactivate it immediately and append its ID to the result. Otherwise, append null. An unmatched payment is not retained for future matching.
Return one result for each PAY event, in event order. Amounts are integer minor currency units; there are no partial payments or currency conversions. Avoid scanning all active invoices for every payment: your implementation must run in O(n log n) total time or better for n events.
Function or class signature
  • reconcile(events: list[dict[str, Any]]) -> list[str | None]


Example 1:
Input:
{"events":[{"type":"OPEN","invoice_id":"inv_b","merchant_id":"m1","currency":"USD","amount":5000,"due_day":10},{"type":"OPEN","invoice_id":"inv_a","merchant_id":"m1","currency":"USD","amount":5000,"due_day":10},{"type":"OPEN","invoice_id":"inv_c","merchant_id":"m1","currency":"USD","amount":5000,"due_day":30},{"type":"PAY","merchant_id":"m1","currency":"USD","amount":5000,"invoice_id":"inv_c"},{"type":"PAY","merchant_id":"m1","currency":"USD","amount":5000,"invoice_id":"missing"},{"type":"PAY","merchant_id":"m1","currency":"USD","amount":5000,"invoice_id":null}]}
Output:
["inv_c","inv_a","inv_b"]
Explanation: The first payment explicitly identifies an eligible invoice, so inv_c wins despite its later due day. The second payment falls back to amount matching; inv_a and inv_b have the same due day, so inv_a wins lexicographically. The final payment matches the remaining invoice.
Example 2:
Input:
{"events":[{"type":"OPEN","invoice_id":"inv_x","merchant_id":"m1","currency":"USD","amount":700,"due_day":1},{"type":"OPEN","invoice_id":"inv_y","merchant_id":"m1","currency":"USD","amount":700,"due_day":4},{"type":"UPDATE","invoice_id":"inv_x","amount":900,"due_day":8},{"type":"PAY","merchant_id":"m1","currency":"USD","amount":700,"invoice_id":"inv_x"},{"type":"CANCEL","invoice_id":"inv_x"},{"type":"PAY","merchant_id":"m1","currency":"USD","amount":900,"invoice_id":null}]}
Output:
["inv_y",null]
Explanation: After the update, inv_x is not eligible for the 700-unit payment, even though its ID was supplied. The fallback selects inv_y. Canceling inv_x leaves no eligible invoice for the 900-unit payment. Any index entries left behind by the update or cancellation must not be treated as active invoices.
Constraints:
  • 0 <= n <= 200000 events; all events follow the schemas above.

  • 1 <= amount <= 10^12; 0 <= due_day <= 10^9.

  • Invoice IDs and merchant IDs contain 1–40 lowercase ASCII letters, digits, or underscores. Currency codes contain exactly three uppercase ASCII letters.

  • Each OPEN uses a previously unused invoice ID. Other events may reference unknown or inactive invoice IDs.

  • Events are processed sequentially in a single process. Use integer arithmetic for amounts.


Follow-up:
What if the events arrive as an unbounded stream and a small set of active invoices is updated millions of times? Modify your indexing strategy so memory is proportional to the number of active invoices rather than the total number of events, while preserving logarithmic update and matching time.
Want to practise this one?
Create a free account to open the full question and practise Stripe questions with AI.
Sign up free
coding Hard sliding window #2

2. [AI Enabled Coding] Reversible Merchant Fraud Monitor


Scenario
Stripe Radar analysts need an internal simulator that identifies merchants with suspicious charge activity and revises those decisions when analysts overturn a charge's fraud classification. Implement the simulator with an AI assistant, checking its assumptions and generated tests yourself. These are hypothetical interview policies, not Stripe's production fraud rules.
Part 1 — Merchant-level policies
  • Process records in input order. Each record is a map of string keys to string values; time is an integer number of seconds encoded as a string. Times are nondecreasing.

  • A CHARGE contains id, time, merchant, category, and fraud, where fraud is exactly "true" or "false". Its id also identifies the charge.

  • A DISPUTE contains id, time, and charge. For this exercise, it means an analyst has overturned the referenced charge's fraud classification: change fraudulent to nonfraudulent without removing the charge from the total. A repeated dispute, a dispute of a nonfraudulent charge, or a dispute of an unknown charge has no effect.

  • Apply two lifetime merchant rules: merchant_count matches when fraudulent charges are at least 3; merchant_ratio matches when total charges are at least 4 and 2 × fraudulent >= total.

  • A merchant is flagged if either rule matches. After every record, return the flagged merchant IDs in lexicographic order, including an unchanged snapshot after a no-op record.

  • Function signature: monitor_merchants(records: list[dict[str, str]]). The return type is up to the candidate; examples use a list of snapshots with event and merchants fields.


Example 1:
Input:
[
  {"type":"CHARGE","id":"c1","time":"0","merchant":"m1","category":"digital","fraud":"true"},
  {"type":"CHARGE","id":"c2","time":"1","merchant":"m1","category":"digital","fraud":"true"},
  {"type":"CHARGE","id":"c3","time":"2","merchant":"m1","category":"digital","fraud":"false"},
  {"type":"CHARGE","id":"c4","time":"3","merchant":"m1","category":"digital","fraud":"true"},
  {"type":"DISPUTE","id":"d1","time":"4","charge":"c1"},
  {"type":"DISPUTE","id":"d2","time":"5","charge":"c2"}
]

Output:
[
  {"event":"c1","merchants":[]},
  {"event":"c2","merchants":[]},
  {"event":"c3","merchants":[]},
  {"event":"c4","merchants":["m1"]},
  {"event":"d1","merchants":["m1"]},
  {"event":"d2","merchants":[]}
]

Explanation: The fraudulent/total counts are 1/1, 2/2, 2/3, 3/4, 2/4, and 1/4. At c4 both rules match. At d1 only merchant_ratio matches because 2 × 2 = 4. At d2 neither matches.
Part 2 — Configurable scopes and rolling windows
Risk teams now need additional policies shared across merchants in the same category, as well as rolling-window merchant policies. Preserve both Part 1 rules and add caller-supplied rules. Discuss how your return type changes before implementing this extension; the approach must be flexible enough to support future rules of the same kinds without adding branches for individual rule IDs.
  • Function signature: monitor_risk(records: list[dict[str, str]], extra_rules: list[dict[str, str]]). Both inputs are lists of maps with string keys and string values.

  • Each extra rule has a unique id, scope (merchant or category), window (lifetime or a positive integer number of seconds), kind (count or ratio), and positive integer min_total.

  • A count rule also has a positive integer threshold. It matches when total >= min_total and fraudulent >= threshold.

  • A ratio rule instead has positive integers numerator and denominator, with numerator <= denominator. It matches when total >= min_total and denominator × fraudulent >= numerator × total. Use exact integer arithmetic.

  • At event time t, a window of width W includes charges with timestamps in (t-W, t]. Expire charges before applying the event. Every event advances time, including no-op disputes. Lifetime rules never expire charges.

  • A category rule aggregates charges from all merchants in that category. Each merchant belongs to exactly one category. A dispute affects every lifetime or rolling rule in which its charge is currently included.

  • After each complete event, report every matching (scope, entity, rule) triple. Sort triples lexicographically by scope, then entity, then rule. Report all matching rules rather than choosing one winner. Examples use event and alerts fields.

  • Maintain rolling counts incrementally: do not rescan historical charges or every known entity after each event. Enumerating currently matching alerts to produce the required output is allowed.


Example 2:
Input:
{
  "extra_rules": [
    {"id":"category_count","scope":"category","window":"10","kind":"count","min_total":"1","threshold":"2"},
    {"id":"category_ratio","scope":"category","window":"10","kind":"ratio","min_total":"3","numerator":"2","denominator":"3"}
  ],
  "records": [
    {"type":"CHARGE","id":"c1","time":"0","merchant":"m1","category":"digital","fraud":"true"},
    {"type":"CHARGE","id":"c2","time":"4","merchant":"m2","category":"digital","fraud":"true"},
    {"type":"CHARGE","id":"c3","time":"6","merchant":"m2","category":"digital","fraud":"false"},
    {"type":"DISPUTE","id":"d1","time":"10","charge":"c1"},
    {"type":"CHARGE","id":"c4","time":"14","merchant":"m1","category":"digital","fraud":"true"}
  ]
}

Output:
[
  {"event":"c1","alerts":[]},
  {"event":"c2","alerts":[{"scope":"category","entity":"digital","rule":"category_count"}]},
  {"event":"c3","alerts":[{"scope":"category","entity":"digital","rule":"category_count"},{"scope":"category","entity":"digital","rule":"category_ratio"}]},
  {"event":"d1","alerts":[]},
  {"event":"c4","alerts":[]}
]

Explanation: At time 4, category counts are 2 fraudulent out of 2 total, so only the count rule matches; the ratio rule requires 3 total. At time 6, counts are 2/3, satisfying both rules, including 3 × 2 = 2 × 3. At time 10, c1 expires because the lower boundary is exclusive; the category has 1/2, and its dispute changes only lifetime counts. At time 14, c2 expires and c4 enters, leaving 1/2 again. No merchant reaches either lifetime threshold.
Example 3:
Input:
{
  "extra_rules": [
    {"id":"category_count","scope":"category","window":"10","kind":"count","min_total":"1","threshold":"2"},
    {"id":"category_ratio","scope":"category","window":"10","kind":"ratio","min_total":"3","numerator":"2","denominator":"3"}
  ],
  "records": [
    {"type":"CHARGE","id":"c1","time":"0","merchant":"m1","category":"digital","fraud":"true"},
    {"type":"CHARGE","id":"c2","time":"1","merchant":"m1","category":"digital","fraud":"true"},
    {"type":"CHARGE","id":"c3","time":"2","merchant":"m1","category":"digital","fraud":"true"},
    {"type":"DISPUTE","id":"d1","time":"3","charge":"c1"},
    {"type":"DISPUTE","id":"d2","time":"4","charge":"c1"}
  ]
}

Output:
[
  {"event":"c1","alerts":[]},
  {"event":"c2","alerts":[{"scope":"category","entity":"digital","rule":"category_count"}]},
  {"event":"c3","alerts":[{"scope":"category","entity":"digital","rule":"category_count"},{"scope":"category","entity":"digital","rule":"category_ratio"},{"scope":"merchant","entity":"m1","rule":"merchant_count"}]},
  {"event":"d1","alerts":[{"scope":"category","entity":"digital","rule":"category_count"},{"scope":"category","entity":"digital","rule":"category_ratio"}]},
  {"event":"d2","alerts":[{"scope":"category","entity":"digital","rule":"category_count"},{"scope":"category","entity":"digital","rule":"category_ratio"}]}
]

Explanation: c3 makes the category 3/3 and the merchant 3/3, matching three rules simultaneously. The merchant ratio rule still fails its minimum of 4 total charges. After d1, counts are 2/3: the merchant count rule clears, while both category rules remain, with the category ratio exactly equal to 2/3. The repeated dispute d2 must not decrement anything again.
Notes:
  • There are at most 200,000 records and 50 extra rules; timestamps are between 0 and 10^12. Output size may be large and must be included in complexity analysis.

  • Inputs follow the stated schemas; event IDs are globally unique, rule IDs are unique and do not use the two reserved default IDs, and merchant categories are consistent.

  • Events with equal timestamps are processed in input order. There are no snapshots or time advancement after the final event.
coding Hard tree #3

3. [OA] Tree — Implement Stripe's payment transaction history

To improve user experience, Stripe needs a data structure to represent users' transaction histories in a way that allows for efficient retrieval and management.
Problem statement: Design a transaction history structure where each transaction has an int transactionId, double amount, string date, and nested transactions. Implement methods to add a transaction and to retrieve the transaction with the highest amount.
  • addTransaction(transactionId: int, amount: double, date: string): void: Add a transaction to the history.

  • getMaxTransaction(): (int, double, string): Returns the ID, amount, and date of the transaction with the highest amount.

Example 1:
Input: addTransaction(1, 100.50, '2023-03-01')
Output: None
Example 2:
Input: addTransaction(2, 200.75, '2023-03-02')
Output: None
Input: getMaxTransaction()
Output: (2, 200.75, '2023-03-02')
Constraints:
  • 1 <= transactionId <= 10^6

  • 0 <= amount <= 10^6

  • date follows the format 'YYYY-MM-DD'.
coding Hard sliding window #4

4. [OA] Sliding Window — Implement a rate-limiting service for Stripe API

In order to protect our APIs from abuse and to ensure fair usage, Stripe requires a sliding window rate limiter that tracks the number of requests for each API key over a given time period.
Problem statement: You need to implement a rate limiter that allows a specified number of requests per minute (e.g., 100 requests) for each unique string apiKey. Ensure that the rate limiter has a method to track requests and should return a boolean indicating whether the request is allowed.
  • trackRequest(apiKey: string): boolean: Returns true if the request is allowed, false otherwise.

Example 1:
Input: trackRequest('key1')
Output: true
Explanation: The request is allowed.
Example 2:
Input: trackRequest('key1') (100 times)
Output: true (first 100 calls)
Output: false (101st call)
Constraints:
  • 1 <= apiKey.length <= 100

  • Rate limit can be bursty but should not exceed specified limits.

  • Simulate up to 10^6 requests.

Start practicing Stripe questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free