Implement a Trie (prefix tree) with insert, search, and startsWith operations — insert adds a word, search checks whether an exact word was inserted, and startsWith checks whether any inserted word begins with a given prefix.
insert("apple"); search("apple")truesearch("app"); startsWith("app")false, trueSolve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →A trie (prefix tree) stores strings character by character along tree edges, so words sharing a prefix share the same path. It turns "does any word start with this prefix?" into a walk proportional to the prefix length instead of a scan of every word.
Original problem on LeetCode ↗