187. Lowest Common Ancestor of a Binary Tree
MediumTree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes. Tree is given as level-order array. p and q are node values.
Examples
Input: [3,5,1,6,2,0,8,null,null,7,4] 5 1
Output: 3
Explanation: Public test case for Lowest Common Ancestor of a Binary Tree
Constraints
- The number of nodes in the tree is in the range [2, 10^5]
- All Node.val are unique.
Loading...
Run checks all cases above. Submit evaluates all test cases.