Medium · Trees
Trie (prefix tree)
Given a list of lowercase words to insert into a trie and a query word, return true if the query was inserted as a complete word and false otherwise — a word that is only a prefix of an inserted word does not count.
Examples
Example 1
{
"insert": ["cat", "car", "can", "dog"],
"search": "car"
}Output: true
Example 2
{
"insert": ["to", "tea", "ten", "i", "in"],
"search": "ten"
}Output: true
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.