15
for(int i=0;i<26;i++){29
void insert(string str,trii* node){31
node->isTerminal=true;35
if(node->dict[index]==NULL ){36
node->dict[index]=new trii(str[0]);38
insert(str.substr(1),node->dict[index]);41
string find(string str,trii* node,string pre){42
if( node->isTerminal==true ){46
if(str.size()==0 || node->dict[index]==NULL){49
return find(str.substr(1),node->dict[index],pre+str[0]);52
string replaceWith(string word ,trii* node){53
string temp=find(word,node,"");61
string replaceWords(vector<string>& dictionary, string sentence) {63
for(int i=0;i<dictionary.size();i++){64
t->insert(dictionary[i],t->root);68
for(int i=0;i<ans.size();i++){70
while(i<ans.size()&&ans[i]!=' '){75
sentence+=t->replaceWith(word,t->root)+" ";