标签:
题目: 236 Lowest Common Ancestor of a Binary Tree
这道题和 235 基本一样
class Solution: # @param {TreeNode} root # @param {TreeNode} p # @param {TreeNode} q # @return {TreeNode} def lowestCommonAncestor(self, root, p, q): if root == None: return root if root == p or root == q: return root left = self.lowestCommonAncestor(root.left, p, q) right = self.lowestCommonAncestor(root.right, p, q) if left != None and right != None: return root if left != None: return left return right
236 Lowest Common Ancestor of a Binary Tree
标签:
原文地址:http://www.cnblogs.com/dapanshe/p/4642758.html