Skip to content

Instantly share code, notes, and snippets.

@CodHeK
Last active June 11, 2020 08:24
Show Gist options
  • Save CodHeK/0e58c9b1d9894673303d1670854013a1 to your computer and use it in GitHub Desktop.
Save CodHeK/0e58c9b1d9894673303d1670854013a1 to your computer and use it in GitHub Desktop.
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