Fraud Hop Network

hard · sql, recursive cte, graphs

Fraud Hop Network (2 Hops)

You are given an account transfer graph and a list of flagged accounts.

Schema:

  • accounts(id, name)
  • transfers(transfer_id, from_account, to_account, amount_cents, transfer_ts)
  • flagged_accounts(account_id)

Create a view named result that lists all accounts reachable by following outgoing transfers from flagged accounts up to 2 hops.

Return the columns:

  • account_id
  • hop_depth (0 for flagged accounts)

If an account is reachable by multiple paths, keep the smallest hop depth. Order by hop_depth, then account_id.

Run tests to see results
No issues detected