I have an array with so much strings and want to search for a pattern on it. This pattern can have some "." wildcard who matches (each) 1 character (any).
For example:
myset = {"bar", "foo", "cya", "test"}
find(myset, "f.o") -> returns true (matches with "foo")
find(myset, "foo.") -> returns false
find(myset, ".e.t") -> returns true (matches with "test")
find(myset, "cya") -> returns true (matches with "cya")
I tried to find a way to implement this algorithm fast because myset
actually is a very big array, but none of my ideas has satisfactory complexity (for example O(size_of(myset) * lenght(pattern))
)
Edit:
myset
is an huge array, the words in it aren't big.
I can do a slow preprocessing. But I'll have so much find()
queries, so find()
I want find()
to be as fast as possible.