KMP and Z-function
Find a pattern in a text in linear time with the prefix function, and read borders and periods straight from the prefix and Z arrays.
The problem
You have a text t of length n and a pattern p of length m. List every position where p occurs in t. Both can have a million characters.
1 of 10