Given a binary search tree (BST), find the lowest common
parent node of two given nodes.
The lowest common parent is the deepest node that has both given nodes as
children (a node can be a child of itself).
Input: root = [10,5,15,2,7,12,20], p = 5, q = 15
Output: 10
Explanation:
The lowest common parent of nodes 5 and 15 is 10.
Input: root = [10,5,15,2,7,12,20], p = 2, q = 7
Output: 5
Explanation:
Node 5 is the parent of both 2 and 7.
Input: root = [3,1,4,null,2], p = 1, q = 2
Output: 1
Explanation:
Node 1 is the parent of node 2 (a node can be its own descendant).
Accepted:
Submission: