Detect Circular Fund Transfer Rings Among Bank Accounts

Last updated: November 29, 2026

Quick Overview

Given a list of transfers (from_account, to_account, amount), find every group of two or more accounts where money can flow from any account back to itself through the group, and return each group with the total amount moved inside it, largest first.

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

0

0

0 solved


Given a list of transfers (from_account, to_account, amount), find every group of two or more accounts where money can flow from any account back to itself through the group, and return each group with the total amount moved inside it, largest first.

Anti-money-laundering analytics is a common Cognizant BFSI engagement, and round-tripping money through a ring of accounts is a classic red flag. The interviewer wants strongly connected components, an iterative implementation that survives millions of accounts, and a clear link between the graph result and the business signal.

What the Interviewer Expects
  • Maps rings to strongly connected components, not just simple cycles
  • Implements Tarjan or Kosaraju correctly
  • Avoids recursion depth limits with an iterative traversal
  • Sums only edges whose endpoints share a component
  • Discusses self-transfers and minimum ring size
  • States O(V + E) complexity
Key Topics to Cover
strongly connected components
Tarjan's algorithm
graph traversal
anti-money laundering
iterative DFS
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
  • Investigators only care about rings that completed within 7 days. How do you add time?
  • How would you list the actual cycles inside a large component for a case file?
  • The transfer graph has 2 billion edges. How would you run this on Spark?
  • How do you suppress legitimate rings such as sweep accounts inside one corporate group?
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

Input: transfers as (src, dst, amount). A ring is a maximal set of at least two accounts where every account can reach every other through transfers in the set, which is exactly a strongly connected...

High-Level Design

Build an adjacency list. Run Tarjan's algorithm: assign each node a discovery index and a low-link (smallest index reachable through the DFS subtree plus one back edge to a node still on the stack). W...


Submit Your Answer
Markdown supported

Related Questions