Typo-Tolerant Autocomplete for Neighborhood and Place Names
Last updated: November 29, 2026
Quick Overview
Build an autocomplete over neighborhood names with popularity scores so that a query returns the most popular names that have some prefix within edit distance d (usually 1) of the query.
Nextdoor
November 29, 20260
0
0 solved
Build an autocomplete over neighborhood names with popularity scores so that a query returns the most popular names that have some prefix within edit distance d (usually 1) of the query.
Nextdoor search has to resolve short, often misspelled place names ("Mision", "Noe Vally") as members type. This harder coding round checks whether you can combine a trie with an incremental Levenshtein DP row and prune the search, rather than computing edit distance against every name.
What the Interviewer Expects
- Explain why computing edit distance against every name is too slow
- Walk the trie carrying one DP row per node so each row is built from its parent in O(m)
- Collect the whole subtree once the path prefix is within d of the full query
- Prune a branch when the minimum value in the row exceeds d
- Rank collected names by popularity with deterministic ties
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 weight exact prefix matches above fuzzy ones?
- How does the work grow if you allow d = 2, and how would you cap it?
- How would you precompute top suggestions per trie node to make exact prefix queries O(m)?
- How would you localize results so nearby neighborhoods rank higher for the member?
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: names with popularity, a query q, max_edits d, and limit. A name matches if some prefix of it is within edit distance d of q (insert, delete, substitute). Return up to limit names sor...
High-Level Design
Insert names into a trie. A DFS from the root carries the DP row row[j] = edit distance between the current trie path and q[:j]. The child's row is computed from the parent's in O(m) with the stan...