82: Lowest common ancestor of a binary search tree
Given a binary search tree
and two nodes node1
and node2
, return lowest common ancestor
value
Note: all
node values
areunique
Example 1
Input: 4 node1 = 4, node1 = 5
/ \
2 5
Output: 4
Example 2
Input: 4 node1 = 2, node1 = 5
/ \
2 5
Output: 4
Helpful article