Пример #1
0
    public IList <bool> CamelMatchTRIE(string[] queries, string pattern)
    {
        TrieNode tn = new TrieNode();

        bool[] ans = new bool[queries.Length];
        for (int i = 0; i < queries.Length; i++)
        {
            tn.AddString(queries[i]);
        }
        HashSet <string> found = tn.SearchForPattern(pattern);

        for (int i = 0; i < queries.Length; i++)
        {
            ans[i] = found.Contains(queries[i]);
        }

        /*
         * bool[] ans = new bool[queries.Length];
         * for(int i=0;i<queries.Length;i++)
         * {
         *  ans[i] = IsMatch(queries[i],pattern);
         * }*/
        return(ans.ToList());
    }