teacher
Sign in

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.

45 minCF 1700–23005 interactive10 problems

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