1#Definition for a binary tree node.2#class TreeNode:3#def __init__(self, val=0, left=None, right=None):4#self.val = val5#self.left = left6#self.right = right7classSolution:8deffindDistance(self, root: Optional[TreeNode], p: int, q: int) ->int:9deffindLca(node, p, q):...
leetcode -- find the lowest common ancestor Given a binary tree, find the lowest common ancestor of two given nodes in the tree. ___3___ / \ ___5__ ___1__ / \ / \6_2 0 8/ \7 4 If you are not so sure about the definition of lowest common ancestor (LCA), please refer...