Autocomplete Assets by Ticker or Name Ranked by Market Cap
Last updated: November 29, 2026
Quick Overview
Build a prefix search over listed assets that matches either the ticker or the start of any word in the asset's name, returning the top k results by market cap for each keystroke.
Coinbase
November 29, 20260
0
0 solved
Build a prefix search over listed assets that matches either the ticker or the start of any word in the asset's name, returning the top k results by market cap for each keystroke.
The Coinbase search bar must return BTC for 'bit' and Ethereum Classic for 'cla' instantly across thousands of assets. The interviewer checks a trie design that precomputes top-k per node so lookups do not traverse subtrees, plus handling of multiple keys per asset.
What the Interviewer Expects
- Insert each asset under its ticker and each name word
- Precompute top k per trie node at insert time
- Avoid duplicate results when an asset reaches a node through two keys
- Make lookups O(prefix length + k)
- Discuss memory trade-offs and updates to market cap
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 update rankings when market caps change every minute?
- How would you add typo tolerance, such as 'etherum'?
- How do you boost assets the user already holds?
- How would you serve this from the edge for mobile clients?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
add(ticker, name, market_cap) and search(prefix) returning up to k (ticker, name) pairs, highest market cap first, case-insensitive. A prefix matches the ticker or the beginning of any name word...
High-Level Design
A trie over lowercase keys. Each node stores the k best (market_cap, ticker) entries in its subtree, updated on the insert path, so search only walks the prefix and reads the node's list. An asset i...