MCPcopy Index your code
hub / github.com/trekhleb/javascript-algorithms / getLastCharacterNode

Method getLastCharacterNode

src/data-structures/trie/Trie.js:96–109  ·  view source on GitHub ↗

* @param {string} word * @return {TrieNode}

(word)

Source from the content-addressed store, hash-verified

94 * @return {TrieNode}
95 */
96 getLastCharacterNode(word) {
97 const characters = Array.from(word);
98 let currentNode = this.head;
99
100 for (let charIndex = 0; charIndex < characters.length; charIndex += 1) {
101 if (!currentNode.hasChild(characters[charIndex])) {
102 return null;
103 }
104
105 currentNode = currentNode.getChild(characters[charIndex]);
106 }
107
108 return currentNode;
109 }
110}

Callers 2

suggestNextCharactersMethod · 0.95
doesWordExistMethod · 0.95

Calls 2

hasChildMethod · 0.80
getChildMethod · 0.80

Tested by

no test coverage detected