Commit a28d87d
committed
feat(strings, trie): is prefix of word
This adds a function `is_prefix_of_word` that enables searching for the
index of a `search_word` in a given sentence and return the index if it
exists. The index is 1-based.
This modifies the `TrieNode` allowing callers to use the `TrieNode` to
build a trie from the node and perform prefix searches a well as
modifies the `Trie` class as well adding modifications and optimizations
that match the changes in the `TrieNode` class.
Also note that this change includes an `index` to the `TrieNode` to
track the earliest index of a given character in a sentence. That is,
what is the earliest that a word has been seen, This allows returning
multiple words in the case of using the `Trie` `search` functionality.1 parent 484b865 commit a28d87d
File tree
27 files changed
+220
-29
lines changed- algorithms/fast_and_slow/happy_number
- images
- example
- solution
- datastructures
- streams/stream_checker
- trees/trie
- pystrings/is_prefix
- images/examples
- tests/datastructures/trees/trie
27 files changed
+220
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
0 commit comments