236 Lowest Common Ancestor of a Binary Tree
题目: 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