Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.
- The
rootof a BST. - Two target nodes
pandq.
Input: root = [6, 2, 8, 0, 4, 7, 9, null, null, 3, 5], p = 2, q = 8
Output: 6
Explanation: The LCA of 2 and 8 is 6.