leetcode 236. Lowest Common Ancestor of a Binary Tree
来源:互联网 发布:淘客cms系统 编辑:程序博客网 时间:2024/05/16 18:03
class Solution(object): def lowestCommonAncestor(self, root, p, q): """ :type root: TreeNode :type p: TreeNode :type q: TreeNode :rtype: TreeNode """ if root in (p,q,None): return root left_res = self.lowestCommonAncestor(root.left,p,q) right_res = self.lowestCommonAncestor(root.right,p,q) if left_res and right_res: return root else: return left_res if left_res else right_res
阅读全文
0 0
- [leetcode] 236.Lowest Common Ancestor of a Binary Tree
- [LeetCode]236.Lowest Common Ancestor of a Binary Tree
- [leetcode] 236.Lowest Common Ancestor of a Binary Tree
- [LeetCode]236. Lowest Common Ancestor of a Binary Tree
- 236. Lowest Common Ancestor of a Binary Tree LeetCode
- [leetcode] 236. Lowest Common Ancestor of a Binary Tree
- leetcode 236. Lowest Common Ancestor of a Binary Tree
- LeetCode-236.Lowest Common Ancestor of a Binary Tree
- LeetCode 236. Lowest Common Ancestor of a Binary Tree
- LeetCode *** 236. Lowest Common Ancestor of a Binary Tree
- leetcode.236. Lowest Common Ancestor of a Binary Tree
- LeetCode - 236. Lowest Common Ancestor of a Binary Tree
- LeetCode 236. Lowest Common Ancestor of a Binary Tree
- [LeetCode] 236. Lowest Common Ancestor of a Binary Tree
- [leetcode] 236. Lowest Common Ancestor of a Binary Tree
- Leetcode 236. Lowest Common Ancestor of a Binary Tree
- Leetcode 236. Lowest Common Ancestor of a Binary Tree
- Leetcode-236. Lowest Common Ancestor of a Binary Tree
- Subversion Server Edge的安装使用
- 升降桥与自动寻物
- win7+vs2010通过map文件和cod文件找到崩溃的代码行
- CSDN如何看自己的排名
- USACO-Section2.2 preface[贪心]
- leetcode 236. Lowest Common Ancestor of a Binary Tree
- 1428:阵前第一功
- IDEA的使用
- SVN版本库备份和恢复
- Android 的MVVM模式的简单应用
- 时间戳与Date相互转换
- 最近的一些基础笔记
- Redis简介
- FreeRTOS_004_FreeRTOSConfig.h配置文件(一)_通用配置