Cluster Wallet Addresses Using the Common Input Heuristic

Last updated: November 29, 2026

Quick Overview

Given on-chain transactions as lists of input addresses, group addresses that are likely controlled by the same entity because they were spent together, then report the number of clusters and every address linked to a flagged one.

Coinbase
Coding & Algorithms
Software Engineer
Coinbase
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given on-chain transactions as lists of input addresses, group addresses that are likely controlled by the same entity because they were spent together, then report the number of clusters and every address linked to a flagged one.

Coinbase's compliance and blockchain analytics teams trace funds and screen deposits that touch sanctioned or stolen-fund addresses. This question checks whether you reach for union-find for incremental connectivity and implement it with path compression and union by size.

What the Interviewer Expects
  • Explain the heuristic: inputs co-spent in one transaction share an owner
  • Choose union-find over repeated BFS for incremental merges
  • Implement path compression and union by size
  • Register addresses that appear alone so they count as clusters
  • Discuss near-constant amortized complexity
Key Topics to Cover
union find
connected components
hashing
blockchain analytics
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
  • CoinJoin transactions break the heuristic; how would you detect and exclude them?
  • How would you scale this to billions of addresses across machines?
  • How do you support un-merging when a heuristic is later found wrong?
  • How would you add change-address detection as a second signal?
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: a list of transactions, each a list of input address strings, and a list of flagged addresses. Output: the count of distinct clusters over all seen addresses and the sorted list of addresses in...

High-Level Design

Each transaction says its inputs belong together, so union every input with the first one. Union-find handles this in near-constant time per merge and naturally absorbs transactions that bridge previo...


Submit Your Answer
Markdown supported

Related Questions