商丘网站制作费用旅游网网站的设计
2026/1/18 3:24:12 网站建设 项目流程
商丘网站制作费用,旅游网网站的设计,已经有域名 如何建网站,wordpress搬家 图片不显示Problem: 745. Prefix and Suffix Search 前缀和后缀搜索 解题过程 ASCII内#xff0c;{刚好在z后面#xff0c;所以算是特殊字符#xff0c;按照提示拼起来#xff0c;然后放入到字典树当中去#xff0c;并且在{后面的前缀需要求出最大的索引 查…Problem: 745. Prefix and Suffix Search 前缀和后缀搜索解题过程ASCII内{刚好在z后面所以算是特殊字符按照提示拼起来然后放入到字典树当中去并且在{后面的前缀需要求出最大的索引查询的话直接在字典树上面找就可以若是空则-1最后返回最大的索引Codeclass trie { public: bool isend false; int index -1; trie* arr[27] {nullptr}; }; class WordFilter { public: trie* root, *ptr; WordFilter(vectorstring words) { root new trie; string tp; for( int i 0; i words.size(); i ) { ptr root; tp - words[i] { words[i]; while(true) { ptr root; tp tp.substr(1, tp.size() - 1); bool pre false; for(int j 0; j tp.size(); j) { if(ptr-arr[tp[j]-a] nullptr) { ptr-arr[tp[j]-a] new trie; } ptr ptr-arr[tp[j]-a]; if(pre) { ptr-index max(ptr-index, i); } if(tp[j]{) pre true; } if(tp[0]{) break; } } } int f(string pref, string suff) { string combine suff { pref; ptr root; for(int i 0; i combine.size(); i) { if(ptr-arr[combine[i]-a]nullptr) { return -1; } ptr ptr-arr[combine[i]-a]; } return ptr-index; } }; /** * Your WordFilter object will be instantiated and called as such: * WordFilter* obj new WordFilter(words); * int param_1 obj-f(pref,suff); */

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询