Find Circular Money Rings in a P2P Transfer Graph
Last updated: November 29, 2026
Quick Overview
Given a list of peer-to-peer transfers (sender, receiver, cents), find every group of two or more accounts where money can flow in a cycle among them, ignoring transfers below a threshold, and rank groups by the total amount moved inside the group.
Onepay
November 29, 20260
0
0 solved
Given a list of peer-to-peer transfers (sender, receiver, cents), find every group of two or more accounts where money can flow in a cycle among them, ignoring transfers below a threshold, and rank groups by the total amount moved inside the group.
OnePay supports domestic and international P2P payments, and circular flows between a few accounts are a classic sign of laundering or promo abuse. The interviewer wants you to recognize the problem as strongly connected components and implement it without recursion limits biting on large graphs.
What the Interviewer Expects
- Model accounts as nodes and qualifying transfers as directed edges
- Recognize that ring membership is exactly SCC membership
- Implement Tarjan or Kosaraju correctly, ideally iteratively
- Exclude self-transfers and single-node components
- Compute per-ring totals and rank them
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you restrict rings to transfers that happened within the same 7-day window?
- The graph has 100 million edges. How would you run this daily, and what would you do incrementally?
- How do you avoid flagging a family that legitimately pays each other back for groceries?
- What features from a ring would you pass to a fraud model?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
A ring is a set of accounts where each can reach every other by following qualifying transfers. Transfers below min_cents are noise and are dropped. Output each ring as a sorted list of accounts plu...
High-Level Design
Build an adjacency set, run Tarjan's SCC algorithm, keep components with at least two nodes, then sum edge amounts where both ends are in the same component. Tarjan finds all SCCs in one DFS using dis...