mercredi 17 avril 2019

How to implement a fastest algorithm for match the prefix with string?

There has about 100K strings - prefixes, now we need to know does a given string is matched with one of these prefixes or not. For example, the prefixes are:

12
123
1234
12345

Now the given string is 123abc, it will matched with "123" prefix; If the given string is 12340098, it will matched with "1234" prefix.

Since there has 100K prefixes, therefore we need a very fast way to match it, how could we use the C++ to implement it ?

Aucun commentaire:

Enregistrer un commentaire