← Stripe Interview Insights

Stripe·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Stripe coding screen for a software engineer role, second part of a payment-matching problem that built on an earlier round. The added timestamp window constraint made it more interesting than a plain equality check.

Questions Asked (1)

Q1

You have a payment and a list of transactions. A transaction matches the payment if the merchant ID and amount are equal AND the transaction's timestamp falls within a configurable window W on either side of the payment's timestamp. Among all matches, return the one closest in time to the payment. Return null if nothing matches. Implement this as a function match(payment, transactions, W).

Algorithms & Data StructuresAPI & Integrations
Author's notes

The first part of this problem (just merchant ID and amount) came in an earlier round, so the timestamp rule was the new wrinkle here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the input format and constraints, then propose an efficient algorithm that filters transactions by merchant ID and amount, checks the timestamp window, and selects the closest match. Discuss trade-offs between sorting, hashing, and early termination, and handle edge cases like multiple matches and null returns.

Pro tip: Mention that in a real payment system, you'd likely index transactions by merchant ID and amount to avoid scanning all transactions, and consider using a balanced BST or sorted list for efficient closest-match queries.

1. Clarify requirements and constraints

Ask about input sizes, whether transactions are sorted, if multiple matches are possible, and the definition of 'closest in time' (absolute difference). Confirm that W is inclusive and that timestamps are comparable.

2. Design the matching logic

Filter transactions where merchant ID and amount match the payment, and the absolute timestamp difference is ≤ W. Then select the transaction with the minimum absolute time difference.

3. Optimize for performance

If transactions are unsorted, a linear scan is O(n). For repeated queries, consider indexing by (merchant ID, amount) and using binary search on sorted timestamps to find the closest match in O(log n).

4. Handle edge cases and return value

Return null if no matches. If multiple matches have the same minimal difference, define a tie-breaker (e.g., earlier timestamp). Ensure the window check uses absolute difference and handles boundary conditions.

5. Test and validate

Walk through examples: exact match, match at window boundary, no match, multiple matches. Discuss time and space complexity and potential improvements.

Key Points to Mention

  • Time complexity: O(n) for single query, O(log n) with pre-processing/indexing
  • Space complexity: O(1) extra for linear scan, O(n) for index
  • Handling of ties: choose the earliest or latest timestamp consistently
  • Inclusive window boundaries (≤ W)
  • Use of absolute difference for 'closest in time'
  • Potential for early termination if transactions are sorted by time

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.