Given a string s and an array of smaller strings, T, how to design a method to search s for each small string in T?

algorithm, java, search, string

Solution

Assuming you have a significant number of smaller strings, Rabin-Karp is the standard way to search for multiple small strings in a very very large string. if You only have a few smaller strings, simply repeating Boyer-Moore for each one might be a better alternative.

Problem

Given a string s and an array of smaller strings, T, design a method to search s for each small string in T. Thanks.

Original source