Exercises
The following exercises provide you with the opportunity to practice with string matching and the sliding window technique. The solutions to these exercises are found in the section Chapter 11.
-
Implement a new version of the DivisionHasher from Chapter 10 so that it can now hash strings instead of integers. Use the approach of the initial_hash function from our final implementation of Rabin-Karp. (I warned you that this would be an exercise!)
-
Here’s a sliding window exercise for you. Write a function that accepts a string. The function should return the maximum number of vowels that are contained within any three-character substring (of the original string).
For example, the correct answer for the string "spider" is 2 since the three-character ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access