且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用搜索字符串。通配符

更新时间:2023-02-18 19:32:20

您可以构建集合中所有可能单词的语料库的后缀树(查看此链接
使用此数据结构,您的复杂性将包括O(n)花费一倍的时间来构建树,其中n是您所有单词的长度之和。

You could build a suffix tree of the corpus of all possible words in your set (see this link) Using this data structure your complexity would include a one time cost of O(n) to build the tree, where n is the sum of the lengths of all your words.

建立树后,查找字符串是否匹配应仅取O(n),其中n为长度的字符串。

Once the tree is built finding if a string matches should take just O(n) where n is length of the string.