The last question of Leetcode's 181st weekly contest is to find the longest equal prefix and suffix of the string. If you directly use the brute force solution, it will time out and you need to use the part of the KMP algorithm. So today it took a long time to learn the KMP algorithm, search I have written a lot of blogs, but I didn’t get a lot of results, so I finally asked the big guys in my class for advice.
Next, I don’t plan to analyze the algorithm in detail. There are too many similar blogs, but I want to use it as a personal record for future reference. The content is derived from the chat history with the boss, and the explanation from the boss is still very rewarding for me. If you don't want to read long explanations, you can take a look at this, maybe you will gain something.
(A sharp contrast between the boss and Tie Hanhan:)
A little understanding of KMP algorithm
Guess you like
Origin blog.csdn.net/weixin_43867940/article/details/105049635
Recommended
Ranking