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

  1. Lowest Common Ancestor of a Binary Search Tree
更多...

class  Solution
 
struct  TreeNodeP
 

函数

 TEST (lowest_common_ancestor_of_a_binary_search_tree, case1)
 

详细描述

  1. Lowest Common Ancestor of a Binary Search Tree

函数说明

◆ TEST()

leetcode::lowest_common_ancestor_of_a_binary_search_tree::TEST ( lowest_common_ancestor_of_a_binary_search_tree  ,
case1   
)

在文件 leetcode_test.cpp2885 行定义.

2885 {
2886 auto *root = new TreeNode(6);
2887 root->left = new TreeNode(2);
2888 root->right = new TreeNode(8);
2889 root->left->left = new TreeNode(0);
2890 root->left->right = new TreeNode(4);
2891 root->left->right->left = new TreeNode(3);
2892 root->left->right->right = new TreeNode(5);
2893 root->right->left = new TreeNode(7);
2894 root->right->right = new TreeNode(9);
2895 Solution s;
2896 ASSERT_EQ(6, s.lowestCommonAncestor(root, root->left, root->right)->val);
2897 }
vector< int > root
Definition: acwing408.cpp:349
static TreeNode * lowestCommonAncestor(TreeNode *root, TreeNode *p, TreeNode *q)
Definition: leetcode.cpp:6104

引用了 leetcode::lowest_common_ancestor_of_a_binary_search_tree::Solution::lowestCommonAncestor(), acwing::acwing836_408::root , 以及 leetcode::TreeNode::val.