← 返回 meta 的题目列表Optimized Lowest Common Ancestor Search with Minimal Parent Queries
类型:online_judge
meta
Given a binary tree and two nodes, devise an algorithm that queries the parent node only when necessary to find the lowest common ancestor of these two nodes in the binary tree.
Example
Input
3,5,1,6,2,0,8,null,null,7,4
5
1