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

#include <leetcode.h>

静态 Public 成员函数

static string dfs (const string &str, TrieNode *node)
 
static string longestWord (vector< string > &words)
 

详细描述

在文件 leetcode.h1772 行定义.

成员函数说明

◆ dfs()

string leetcode::longest_word_in_dictionary::Solution::dfs ( const string &  str,
TrieNode node 
)
static

在文件 leetcode.cpp4630 行定义.

4630 {
4631 string ans = str;
4632 for(auto *next: node->nexts) {
4633 if(next != nullptr && next->end_of_word) {
4634 string ret = dfs(str + next->ch, next);
4635 if(ans.length() < ret.length()) {
4636 ans = ret;
4637 }
4638 }
4639 }
4640 return ans;
4641 }
static string dfs(const string &str, TrieNode *node)
Definition: leetcode.cpp:4630
array< TrieNode *, 26 > nexts
Definition: templates.h:11

引用了 dfs() , 以及 TrieNode::nexts.

被这些函数引用 dfs() , 以及 longestWord().

◆ longestWord()

string leetcode::longest_word_in_dictionary::Solution::longestWord ( vector< string > &  words)
static

在文件 leetcode.cpp4622 行定义.

4622 {
4623 auto root = TrieNode('0');
4624 for(const auto &word: words) {
4625 root.insert(word);
4626 }
4627 return dfs("", &root);
4628 }
vector< int > root
Definition: acwing408.cpp:349
字典树节点
Definition: templates.h:9

引用了 dfs() , 以及 acwing::acwing836_408::root.

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


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