Easy
Find the lowest common ancestor of two nodes in a BST.
Given a BST and two nodes p and q, return their lowest common ancestor.
Examples
Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8
Output: 6
Constraints
- Both nodes exist in the BST
Coding Challenge
Find the lowest common ancestor of two nodes in a BST.
Given a BST and two nodes p and q, return their lowest common ancestor.
Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8
Output: 6
Preparing your coding workspace...