Answer to Question 1
Practice Questions for Exam 6

Compute the KMP prefix function π for s. If s has length n, then π[n] is the length of the longest proper prefix of s that is also a suffix of s.