From 6e2ff9b6040a8ef4e80dc42768190dd78ce24323 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Sat, 25 Aug 2018 13:34:05 +0300 Subject: [PATCH] Add comments to Trie "add" method. --- src/data-structures/trie/TrieNode.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data-structures/trie/TrieNode.js b/src/data-structures/trie/TrieNode.js index f24910f1..188d72be 100644 --- a/src/data-structures/trie/TrieNode.js +++ b/src/data-structures/trie/TrieNode.js @@ -30,6 +30,8 @@ export default class TrieNode { } const childNode = this.children.get(character); + + // In cases similar to adding "car" after "carpet" we need to mark "r" character as complete. childNode.isCompleteWord = childNode.isCompleteWord || isCompleteWord; return childNode;