**Problem Statement:**
Given the required input arguments, write an efficient algorithm to solve the **Lowest Common Ancestor of BST** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge.
**Hint / Expected Approach:**
Exploit BST property: navigate by value
**Edge Cases to Consider:**
- (1) One node is ancestor of other
- (2) Both nodes same
- (3) Nodes at opposite extremes
Examples
Example 1
Input:[6,2,8,0,4,7,9,null,null,3,5], p=2, q=8
Output:Node 6
Explanation: Root is LCA
Example 2
Input:[6,2,8,0,4,7,9,null,null,3,5], p=2, q=4
Output:Node 2
Explanation: p is ancestor of q
Example 3
Input:[2,1], p=2, q=1
Output:Node 2
Explanation: Root and child
Constraints
▪The number of nodes in the tree is in the range [0, 2000]
▪-1000 <= Node.val <= 1000
▪Ensure depth-first or breadth-first traversals are memory-efficient