简体   繁体   中英

strstr() vs Knuth Morris Pratt

有人可以帮我了解哪个是更有效的strstr()或KMP吗?最近我在SPOJ上进行了一个问题,发现strstr()的速度或某种方式比KMP快。 。

You are comparing apples with pears, strstr() is a function to find substrings, KMP is an algorithm to do it, so strstr() could theoretically be implemented using KMP. You need to find out which algorithm is the strstr() in question implementing to give a statement.

Take a look at this answer and the comments on it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM