Skip to content

Commit a28d87d

Browse files
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

27 files changed

+220
-29
lines changed

algorithms/fast_and_slow/happy_number/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ Return TRUE if n is a happy number, and FALSE if not.
1515

1616
### Sample Example 1
1717

18-
![Sample Example 1.1](example_1_1.png)
19-
![Sample Example 1.2](example_1_2.png)
20-
![Sample Example 1.3](example_1_3.png)
18+
![Sample Example 1.1](images/example/example_1_1.png)
19+
![Sample Example 1.2](images/example/example_1_2.png)
20+
![Sample Example 1.3](images/example/example_1_3.png)
2121

2222
### Sample Example 2
2323

24-
![Sample Example 2.1](example_2_1.png)
25-
![Sample Example 2.2](example_2_2.png)
26-
![Sample Example 2.3](example_2_3.png)
24+
![Sample Example 2.1](images/example/example_2_1.png)
25+
![Sample Example 2.2](images/example/example_2_2.png)
26+
![Sample Example 2.3](images/example/example_2_3.png)
2727

2828
## Solution Example
2929

3030
Below shows an example using Floyd's Cycle Detection Algorithm or Tortoise and Hare algorithm to detect a cycle
3131
for the number 2.
3232

33-
![Solution Example 1](solution_example_1.png)
34-
![Solution Example 2](solution_example_2.png)
35-
![Solution Example 3](solution_example_3.png)
36-
![Solution Example 4](solution_example_4.png)
37-
![Solution Example 5](solution_example_5.png)
38-
![Solution Example 6](solution_example_6.png)
39-
![Solution Example 7](solution_example_7.png)
40-
![Solution Example 8](solution_example_8.png)
33+
![Solution Example 1](images/solution/solution_example_1.png)
34+
![Solution Example 2](images/solution/solution_example_2.png)
35+
![Solution Example 3](images/solution/solution_example_3.png)
36+
![Solution Example 4](images/solution/solution_example_4.png)
37+
![Solution Example 5](images/solution/solution_example_5.png)
38+
![Solution Example 6](images/solution/solution_example_6.png)
39+
![Solution Example 7](images/solution/solution_example_7.png)
40+
![Solution Example 8](images/solution/solution_example_8.png)

algorithms/fast_and_slow/happy_number/example_1_1.png renamed to algorithms/fast_and_slow/happy_number/images/example/example_1_1.png

File renamed without changes.

algorithms/fast_and_slow/happy_number/example_1_2.png renamed to algorithms/fast_and_slow/happy_number/images/example/example_1_2.png

File renamed without changes.

algorithms/fast_and_slow/happy_number/example_1_3.png renamed to algorithms/fast_and_slow/happy_number/images/example/example_1_3.png

File renamed without changes.

algorithms/fast_and_slow/happy_number/example_2_1.png renamed to algorithms/fast_and_slow/happy_number/images/example/example_2_1.png

File renamed without changes.

algorithms/fast_and_slow/happy_number/example_2_2.png renamed to algorithms/fast_and_slow/happy_number/images/example/example_2_2.png

File renamed without changes.

algorithms/fast_and_slow/happy_number/example_2_3.png renamed to algorithms/fast_and_slow/happy_number/images/example/example_2_3.png

File renamed without changes.

algorithms/fast_and_slow/happy_number/solution_example_1.png renamed to algorithms/fast_and_slow/happy_number/images/solution/solution_example_1.png

File renamed without changes.

algorithms/fast_and_slow/happy_number/solution_example_2.png renamed to algorithms/fast_and_slow/happy_number/images/solution/solution_example_2.png

File renamed without changes.

algorithms/fast_and_slow/happy_number/solution_example_3.png renamed to algorithms/fast_and_slow/happy_number/images/solution/solution_example_3.png

File renamed without changes.

0 commit comments

Comments
 (0)