* @param {string} word * @return {TrieNode}
(word)
| 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 | } |
no test coverage detected