Trace Where Funds Could Flow Through Time-Ordered Transfers Within K Hops

Last updated: November 29, 2026

Quick Overview

Given transfers `(from, to, timestamp)` between accounts, a source account and a start time, find every account that could have received money originating at the source through a chain of at most `k` transfers whose timestamps never decrease, with its minimum hop count and earliest arrival time.

Stripe
Coding & Algorithms
Software Engineer
Stripe
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given transfers `(from, to, timestamp)` between accounts, a source account and a start time, find every account that could have received money originating at the source through a chain of at most `k` transfers whose timestamps never decrease, with its minimum hop count and earliest arrival time.

When Stripe's risk and financial crimes teams investigate a compromised account, they need to know where money could have moved afterwards, and a transfer only matters if it happened after the funds arrived. The interviewer checks that you model time-respecting paths correctly, see why plain BFS on the static graph overcounts, and bound the search by hops.

What the Interviewer Expects
  • Explain why static reachability is wrong: a transfer before the funds arrived cannot carry them
  • Process in hop layers so the hop limit is exact
  • Track earliest arrival per account, since earlier arrival can only enable more transfers
  • Use the previous layer's arrivals when relaxing so one round equals one hop
  • Report both minimum hops and earliest arrival, and note they may come from different paths
Key Topics to Cover
graphs
BFS layers
temporal paths
Bellman-Ford style relaxation
financial crimes
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you also bound the amount, so an account cannot forward more than it received?
  • How would you run this over billions of transfers stored in a warehouse?
  • What if you need the actual path for each account as evidence?
  • How does the cost change if k is unbounded?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Funds are at source from time t0. A transfer (u, v, ts) carries them if funds have reached u at or before ts. Output: dict account -> (min_hops, earliest_arrival) for every account other t...

High-Level Design

Keep arrival[v], the earliest time funds can be at v using at most h hops. Round h relaxes every transfer against the arrival map from round h - 1: if prev[u] <= ts, then `cur[v] = min(cur...


Submit Your Answer
Markdown supported