Last active
June 11, 2020 08:24
-
-
Save CodHeK/0e58c9b1d9894673303d1670854013a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find(word) { | |
let root = this.trie; | |
for(const letter of word) { | |
if(letter in root.children) { | |
root = root.children[letter]; | |
} | |
else { | |
return null; // if not found return null | |
} | |
} | |
return root; // return the root where it ends search | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment