words_ending_here
, and words_starting_here
counters.insert
method to traverse the Trie, creating nodes as necessary, incrementing words_starting_here
at each node along the path, and incrementing words_ending_here
at the final node.countWordsEqualTo
by traversing the Trie following the word's characters and returning the words_ending_here
counter of the last node.countWordsStartingWith
by traversing the Trie following the prefix's characters and returning the words_starting_here
counter of the last node.erase
by traversing the Trie, decrementing words_starting_here
at each node along the path, and decrementing words_ending_here
at the final node.