public static List <bool> MultistringSearch(string bigstring, string[] smallstrings) { // Write your code here. TrieSuffix trie = new TrieSuffix(); foreach (string small in smallstrings) { trie.InsertString(small); } HashSet <string> containedStrings = new HashSet <string>(); for (int i = 0; i < bigstring.Length; i++) { matchBigString(bigstring, i, trie, containedStrings); } return(populateBooleanStrings(smallstrings, containedStrings)); }
private static void matchBigString(string bigstring, int startIdx, TrieSuffix trie, HashSet <string> containedStrings) { TrieNode node = trie.root; for (int i = startIdx; i < bigstring.Length; i++) { char ch = bigstring[i]; if (!node.children.ContainsKey(ch)) { break; } node = node.children[ch]; if (node.children.ContainsKey(trie.endSymbol)) { containedStrings.Add(node.word); } } }