problemscpp
A collection of my answers to algorithm problems in c++.
| 函数
leetcode::all_ancestors_of_a_node_in_a_directed_acyclic_graph 命名空间参考

LeetCode 5300. 有向无环图中一个节点的所有祖先 更多...

class  Solution
 

函数

 TEST (all_ancestors_of_a_node_in_a_directed_acyclic_graph, case1)
 
 TEST (all_ancestors_of_a_node_in_a_directed_acyclic_graph, case2)
 

详细描述

LeetCode 5300. 有向无环图中一个节点的所有祖先

函数说明

◆ TEST() [1/2]

leetcode::all_ancestors_of_a_node_in_a_directed_acyclic_graph::TEST ( all_ancestors_of_a_node_in_a_directed_acyclic_graph  ,
case1   
)

在文件 leetcode_test.cpp2002 行定义.

2002 {
2003 vector<vector<int>> input = {{0, 3}, {0, 4}, {1, 3}, {2, 4}, {2, 7}, {3, 5}, {3, 6}, {3, 7}, {4, 6}};
2004 const vector<vector<int>> output = {{}, {}, {}, {0, 1}, {0, 2}, {0, 1, 3}, {0, 1, 2, 3, 4}, {0, 1, 2, 3}};
2005 auto sol = Solution();
2006 ASSERT_EQ(output, sol.getAncestors(8, input));
2007 }

◆ TEST() [2/2]

leetcode::all_ancestors_of_a_node_in_a_directed_acyclic_graph::TEST ( all_ancestors_of_a_node_in_a_directed_acyclic_graph  ,
case2   
)

在文件 leetcode_test.cpp2009 行定义.

2009 {
2010 vector<vector<int>> input = {{0, 1}, {0, 2}, {0, 3}, {0, 4}, {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}};
2011 const vector<vector<int>> output = {{}, {0}, {0, 1}, {0, 1, 2}, {0, 1, 2, 3}};
2012 auto sol = Solution();
2013 ASSERT_EQ(output, sol.getAncestors(5, input));
2014 }