Step 1 of 4
TrieNode & Word Insertion
Start by understanding the TrieNode structure and implement insert(word).
- Each
TrieNodehas achildrendictionary/map and a booleanisEndOfWord/is_end_of_word. insert(word): Walk down the tree starting atroot. For each character, if a child node does not exist, create a newTrieNode. Finally, setisEndOfWord = trueon the last node.
Your build
Running is free — Submit is what records the step. Or press ⌘↩
Tests
1 case| call | type | expected | result |
|---|---|---|---|
| runOps([["insert","apple"],["insert","app"],["search","apple"],["search","app"]]) | inserts single and overlapping words | [null,null,true,true] | — |
Hints
Stuck? Hints open one at a time, each giving a little more away.
3 hints left