标签:搜索 mon comm col roo 公共祖先 tree python nod
class Solution: def lowestCommonAncestor(self, root: ‘TreeNode‘, p: ‘TreeNode‘, q: ‘TreeNode‘) -> ‘TreeNode‘: if p.val>q.val: p,q=q,p if q.val<root.val: return self.lowestCommonAncestor(root.left,p,q) elif p.val>root.val: return self.lowestCommonAncestor(root.right,p,q) else: return root
标签:搜索 mon comm col roo 公共祖先 tree python nod
原文地址:https://www.cnblogs.com/taoyuxin/p/11890360.html