TTesla·DSASDE-2Onsite – Coding 1
Implement a Prefix Search (Trie)
Problem
Design a dictionary supporting insert(word) and startsWith(prefix) for autocomplete.
Example
insert("car"); startsWith("ca") -> true; startsWith("cb") -> false
Constraints
- Up to 10^5 words
Approach
Trie with children map; discuss memory vs a sorted-array binary search alternative.
added 6 days ago