problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::UhWRSj::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static string replaceWords (vector< string > &dictionary, const string &sentence)
 

详细描述

在文件 leetcode.h579 行定义.

成员函数说明

◆ replaceWords()

string leetcode::UhWRSj::Solution::replaceWords ( vector< string > &  dictionary,
const string &  sentence 
)
static

在文件 leetcode.cpp1264 行定义.

1264 {
1265 auto oss = ostringstream();
1266 auto *const nstr = new char[sentence.length() + 1];
1267 auto tn = TrieNode();
1268 for(const auto &root: dictionary) {
1269 tn.insert(root);
1270 }
1271 strcpy(nstr, sentence.c_str());
1272 char *word = strtok(nstr, " ");
1273 while(word != nullptr) {
1274 oss << tn.get_prefix("", string(word)) << " ";
1275 word = strtok(nullptr, " ");
1276 }
1277 const string ans = oss.str();
1278 delete[] nstr;
1279 return ans.substr(0, ans.length() - 1);
1280 }
vector< int > root
Definition: acwing408.cpp:349
字典树节点
Definition: templates.h:9

引用了 acwing::acwing836_408::root.

被这些函数引用 leetcode::UhWRSj::TEST().


该类的文档由以下文件生成: