I want to count the existence of words in textToBeTested array from expList.
Note that both expList and textToBeTested arrays can very large.
I can simply traverse both lists and use ".matches" method to count, but it is in O(n^2).
Is there any faster algorithm or implementation I can use?
String[] expList = {"i", "i'd", "i'll", "i'm", "i'm", "bet[a-zA-Z]*", "my[a-zA-Z]*"};
String[] textToBeTested = {"this", "is", "better", "than", "my", "method"};
e.g. in the above textToBeTested array, "better" and "my" matches with a string in expList arrays, so it will return 2.
Thank you very much for any help.