Given a binary search tree and two nodes p and q, find their lowest common ancestor (LCA).
Input: root=[6,2,8,0,4,7,9], p=2, q=8 Output: 6 Input: root=[6,2,8,0,4,7,9], p=2, q=4 Output: 2
Unlock hints progressively β start gentle, go deeper only if needed.
Level 1: Gentle Nudge
A subtle direction
Level 2: Approach
The algorithm to use
Level 3: Detailed
Step-by-step guidance
to save progress and use AI features