← AlgoMindset 75

Implement Trie (Prefix Tree)

Medium🎙 Interview me on this

🧠 Before you code — what pattern fits?

Implement the Trie class: insert(word) stores a word; search(word) returns true if word was inserted; startsWith(prefix) returns true if any inserted word has the given prefix.

insert("apple"); search("apple")=true; search("app")=false; startsWith("app")=true

🎬 Video explanation · NeetCode

Your solution runs against 1 unit tests, including edge and large-value cases.

Loading...

Test console · 1 unit tests

Submit your code to run it against all 1 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.

Want the full interview treatment — the conversation, the why, and step-by-step visuals? Read the deep dive →