1644. Lowest Common Ancestor of a Binary Tree II
Last updated
Last updated
**Input:** root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1
**Output:** 3
**Explanation:** The LCA of nodes 5 and 1 is 3.**Input:** root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4
**Output:** 5
**Explanation:** The LCA of nodes 5 and 4 is 5. A node can be a descendant of itself according to the definition of LCA.**Input:** root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 10
**Output:** null
**Explanation:** Node 10 does not exist in the tree, so return null.