Problem :

https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/


My Solution :

# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None

class Solution:
def lowestCommonAncestor(self, root, p, q):
if root in (p, q, None):
return root
left = self.lowestCommonAncestor(root.left, p, q)
right = self.lowestCommonAncestor(root.right, p, q)
return root if (left and right) else (left or right)
secret