Step 2 of 4
Exact Word Search
You start from the build so far — your own work where you have written it, the reference build where you have not. Either way this step stands on its own.
Implement search(word) to verify if an exact word exists in the Trie.
- Start at the root and follow the character path for each letter in
word. - If any character node is missing, return
false. - If all characters exist, return
trueonly if the final node is marked withisEndOfWord === true(a prefix alone is not a valid whole word).
Your build
Running is free — Submit is what records the step. Or press ⌘↩
Tests
1 case| call | type | expected | result |
|---|---|---|---|
| runOps([["insert","apple"],["search","apple"],["search","app"],["search","appl"],["search","orange"]]) | distinguishes complete words from prefixes | [null,true,false,false,false] | — |
Hints
Stuck? Hints open one at a time, each giving a little more away.
2 hints left