KMP on geeksforgeeks, with a well-commented C code. I am sorry that I am still inable to give a personal explanation of the algorithm. I only read it from the two links above and mimic the code in the second lin