求二叉树中和为给定值的所有路径

2014-11-24 12:33:28 · 作者: · 浏览: 2


问题定义:


You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum up to that value. Note that it can be any path in the tree-it does not have to start at the root.


解题思路:


代码实例:





运行结果如下: