

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 8
click for more info
Not enough gems
Cost: 6 gems
1: Tries
incomplete
2: Exists
incomplete
3: Prefix Matching
incomplete
4: Words With Prefix
incomplete
5: Find Matches
incomplete
6: Find Matches Review
incomplete
7: Longest Common Prefix
incomplete
8: Advanced Find Matches
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Tries are super efficient when it comes to finding substrings in a large document of text. For LockedIn, we want to be able to find all of the instances of bad words in chat messages and filter them out.
If we just split on whitespace and matched against a dictionary, we would miss substrings. For example, if we had the word "darn" in our dictionary, we would allow the word "darnit" to slip through undetected. That's why we'll use a trie.
Complete the find_matches method. It takes an entire document string as input and returns a set() of all the words from the trie that occur in the document.