Sale
Summer Offer: $190/yr $99/yr
00 : 00 : 00 : 00
Get this deal
Backend Engineering Mid programming

LeetCode #208 - Implement Trie (Prefix Tree)

Implement a trie with insert, search, and startsWith methods. A trie (pronounced as 'try') is a special data structure used to store a dynamic set or associative array where the keys are usually strings. It is a tree-like data structure where each node represents a character of the string.
Example:
Input:
"insert" - "apple"
"search" - "apple"
"search" - "app"
"startsWith" - "app"
"insert" - "app"
"search" - "app"
Output:
true
false
true
true
Constraints:
1. All inputs are lowercase letters a-z.
2. The inputs are strings of at most 200 characters.
3. The maximum number of inserts in the trie is 10000.
Suggested Answer

Trusted by 100+ professionals preparing for interviews

Trusted by 100+ professionals 50+ Company Question Banks 5+ Supported Languages

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

Get Started Free

More Backend Engineering Interview Prep

Describe the differences between a monolithic architecture and a microservices architecture. What would be your approach to decide which one to use for a new project?
Backend Engineering · Mid
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Link copied to clipboard