Step 1 of 4

TrieNode & Word Insertion

Start by understanding the TrieNode structure and implement insert(word).

  • Each TrieNode has a children dictionary/map and a boolean isEndOfWord / is_end_of_word.
  • insert(word): Walk down the tree starting at root. For each character, if a child node does not exist, create a new TrieNode. Finally, set isEndOfWord = true on the last node.

Your build

Running is free — Submit is what records the step. Or press ⌘↩

Tests

1 case
calltypeexpectedresult
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