Given the root of a binary search tree and two values p and q that are present in the tree, return the value of their lowest common ancestor (LCA).
The LCA of p and q is the deepest node that has both of them as descendants (a node is allowed to be a descendant of itself). Note that p and q are passed as plain node values, and you must return the value of the LCA node (not the node object).
The tree is given in level-order (TreeNode with { val, left, right }, null for a missing child).
[6,2,8,0,4,7,9,null,null,3,5], 2, 8[6,2,8,0,4,7,9,null,null,3,5], 2, 4[2,1], 2, 1[6,2,8,0,4,7,9,null,null,3,5], 3, 5[6,2,8,0,4,7,9,null,null,3,5], 0, 5[5,3,8,1,4,7,9], 7, 9