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
November 29, 20260
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
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
- 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 ProblemsSample 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...