Today I was trying to solve the problem CF R1600 — Camp Schedule. I realized that I will need the longest prefix of a string which is also a suffix of that string. I searched it on google and found that it is called 'Prefix Function'. I tried to understand this concept from the CP Algorithms article, but I am too dumb to understand it.
Though I got the code from there what I needed, I can't understand how it works. Can anyone please help me to understand this concept? (with some examples?)
Note: I am very new to this type of algorithms.