give binary tree find low common ancestor LCA give node treeaccorde definition LCA Wikipedia the low common ancestor define node p q low node T p q descendant allow node descendant Example 1input root 3516208nullnull74 p 5 q 1output 3explanation the LCA nod 5 1 3example 2input root 3516208nullnull74 p 5 q 4output 5explanation the LCA nod 5 4 5 node descendant accord LCA definitionexample 3input root 12 p 1 q 2output 1 ConstraintsThe number nod tree range 2 105109 Nodeval 109All Nodeval uniquep qp q exist tree