Tree 总结
http://leetcode.com/2011/07/lowest-common-ancestor-of-a-binary-tree-part-i.html
两种思路:
top-down bottom-up
递归实现,递归里面可以添加小递归方法. n^2
自己总结的万能思路
首先1. top-down 还是 bottom-up. 选择top-down 2. 用递归. 是否需要内嵌小递归. 需要. 其实就是判定root的是否一样的小递归. 3. 逻辑运用小递归.
http://leetcode.com/2011/07/lowest-common-ancestor-of-a-binary-tree-part-i.html
两种思路:
top-down bottom-up
递归实现,递归里面可以添加小递归方法. n^2
自己总结的万能思路
首先1. top-down 还是 bottom-up. 选择top-down 2. 用递归. 是否需要内嵌小递归. 需要. 其实就是判定root的是否一样的小递归. 3. 逻辑运用小递归.