The Problem: A large static list of strings is provided as A
, A long string is provided as B
, strings in A
are all very short (a keywords list), I want to check if every string in A
is a sub-string of B
and get them.
Now I use a simple loop like:
result = []
for word in A:
if word in B:
result.append(word)
But it's crazy slow when A contains ~500,000 or more items.
Is there any library or algorithm that fits this problem? I've tried my best to search but no luck.
Thank you!