I have an array of n strings. I want to select all the elements of the array that contains the given string. For example
input = "ra"
array = ["abas", "aras", "as", "ask", "asi", "aso", "atras", "ram" ]
output = ["aras", "atras", "ram"]
My solution is brute-force, O(array.length*pattern.length*text.length)
. I wonder, is any possible way to do this faster? Or somehow use Trie (which apparently works for search only from start (!not in any position))?