How do they search inside a string
What is the most efficient way to do this? There must be some better me开发者_如何学Cthod other than brute force.
Depends on length of string, size of alphabet and whether repeated searching: Knuth-Morris-Pratt, Rabin-Karp, etc.
See String searching algorithm
Knuth-Morris-Pratt algorithm
Rabin-Karp algorithm
精彩评论