This tests whether you can use BST ordering to optimize. The brute force (checking all paths) is . Using BST properties gives . Interviewers often follow up with: "What if it's not a BST?" That's a different problem (LCA of Binary Tree) where you must search both subtrees and check if p and q are found. This is also a common system design interview question when discussing tree-based data structures or hierarchical data.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/trees-bst/lowest-common-ancestor-of-bst-why-this-problem
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████████████████████████████████████████████████████████████████████████████████████████████████████████