LintCode:最近公共祖先
来源:互联网 发布:php.ini设置文件大小 编辑:程序博客网 时间:2024/06/06 10:05
LintCode:最近公共祖先
"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""import copyclass Solution: """ @param root: The root of the binary search tree. @param A and B: two nodes in a Binary. @return: Return the least common ancestor(LCA) of the two nodes. """ def lowestCommonAncestor(self, root, A, B): # write your code here if root == None: return None if root == A or root == B: return root left = self.lowestCommonAncestor(root.left, A, B) right = self.lowestCommonAncestor(root.right, A, B) if left and right: return root elif left: return left elif right: return right else: return None
0 0
- LintCode-最近公共祖先
- LintCode 最近公共祖先
- LintCode:最近公共祖先
- LintCode:最近公共祖先
- lintcode-最近公共祖先
- 最近公共祖先,lintcode
- lintcode, 最近公共祖先
- 最近公共祖先-LintCode
- lintcode--最近公共祖先
- lintcode----最近公共祖先
- lintcode-最近公共祖先-88
- [LintCode]88.最近公共祖先
- LintCode-剑指Offer-(88)最近公共祖先
- lintcode lowest-common-ancestor 最近公共祖先
- [Lintcode]Lowest Common Ancestor 最近公共祖先
- LintCode:M-最近祖先
- 最近公共祖先LCA
- 最近公共祖先(LCA)
- Hadoop集群部署介绍
- rw_《计算机是怎样跑起来的》12 章 & 总结
- Android Studio运行程序出现Session ‘app’: Error Launching activity 解决办法
- 【[NOIP2009】靶形数独 题解
- Leetcode 234. Palindrome Linked List
- LintCode:最近公共祖先
- 学习js
- Java垃圾回收机制
- 基础系列(一):命令
- sublime text3环境下的python即时编译插件
- linux实施流量监测工具 mark
- Gym 100960G Youngling Tournament(splay)
- 图论练习册
- [4] rw_《CSAPP》2Ed 8 11-12 章 《APUE》15章·简