lowest-common-ancestor-of-a-binary-search-tree 1.0.0
Lowest Common Ancestor of a Binary Search Tree
Loading...
Searching...
No Matches
main.cpp File Reference
#include <bits/stdc++.h>
Include dependency graph for main.cpp:

Go to the source code of this file.

Data Structures

struct  TreeNode
 Definition for a binary tree node. More...
 
class  Solution
 

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 46 of file main.cpp.

47{
48 unique_ptr<TreeNode> root(make_unique<TreeNode>(6));
49 unique_ptr<TreeNode> p(make_unique<TreeNode>(2));
50 unique_ptr<TreeNode> q(make_unique<TreeNode>(8));
51 root->left = p.get();
52 root->right = q.get();
53 cout << "output: " << Solution().lowestCommonAncestor(root.get(), p.get(), q.get())->val << '\n';
54 return 0;
55}
TreeNode * lowestCommonAncestor(TreeNode *root, TreeNode *p, TreeNode *q)
Definition main.cpp:19
int val
Definition main.cpp:10

References Solution::lowestCommonAncestor(), and TreeNode::val.