We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6469d5f commit a6b3ce7Copy full SHA for a6b3ce7
src/_DataStructures_/Trees/Trie/Node.js
@@ -3,6 +3,7 @@ class TrieNode {
3
this.char = char;
4
this.children = [];
5
this.isEndOfWord = false;
6
+ this.wordCount = 0;
7
8
// mark all the alphabets as null
9
for (let i = 0; i < 26; i += 1) this.children[i] = null;
@@ -15,6 +16,10 @@ class TrieNode {
15
16
unmarkAsLeaf() {
17
18
}
19
+
20
+ increaseCount() {
21
+ this.wordCount += 1;
22
+ }
23
24
25
module.exports = TrieNode;
src/_DataStructures_/Trees/Trie/index.js
@@ -32,6 +32,7 @@ class Trie {
32
// when we are done with inserting all the character of the word,
33
// mark the node as end leaf
34
currentNode.markAsLeaf();
35
+ currentNode.increaseCount();
36
return true;
37
38
0 commit comments