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

#include <leetcode.h>

静态 Public 成员函数

static vector< vector< int > > allPathsSourceTarget (vector< vector< int > > &graph)
 
static int dfs (vector< vector< int > > &graph, vector< vector< int > > &ans, int cur)
 

详细描述

在文件 leetcode.h2390 行定义.

成员函数说明

◆ allPathsSourceTarget()

vector< vector< int > > leetcode::all_paths_from_source_to_target::Solution::allPathsSourceTarget ( vector< vector< int > > &  graph)
static

在文件 leetcode.cpp6407 行定义.

6407 {
6408 vector<vector<int>> ans;
6409 dfs(graph, ans, 0);
6410 for(auto &path: ans) {
6411 path.push_back(0);
6412 path = vector(path.rbegin(), path.rend());
6413 }
6414 return ans;
6415 }
static int dfs(vector< vector< int > > &graph, vector< vector< int > > &ans, int cur)
Definition: leetcode.cpp:6417

引用了 dfs().

◆ dfs()

int leetcode::all_paths_from_source_to_target::Solution::dfs ( vector< vector< int > > &  graph,
vector< vector< int > > &  ans,
int  cur 
)
static

在文件 leetcode.cpp6417 行定义.

6417 {
6418 int ret = 0;
6419 if(cur == graph.size() - 1) {
6420 ans.emplace_back(vector(1, cur));
6421 return 1;
6422 }
6423 for(const auto next: graph[cur]) {
6424 const int n = dfs(graph, ans, next);
6425 ret += n;
6426 for(int i = ans.size() - 1, j = 0; j < n; i--, j++) {
6427 ans[i].emplace_back(cur);
6428 }
6429 }
6430 return ret;
6431 }

引用了 dfs().

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


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