class Solution {
public int pathSum(TreeNode root, int sum) {
findPath(root,new Stack<Integer>());
return 0;
}
public static void findPath(TreeNode root,Stack<Integer> stack){
stack.push(root.val);
if(root.left == null && root.right == null){
for(Integer i:stack){
System.out.print(i+" ");
}
}
if(root.left!=null)
findPath(root.left,stack);
if(root.right!=null)
findPath(root.right,stack);
//返回父节点
//在返回父节点前,在路径上删除当前结点
stack.pop();
}
}