import java.util.*; public class Solution { ArrayList<ArrayList<Integer>> res_list = new ArrayList<>(); Stack<Integer> stack = new Stack<>(); public ArrayList<ArrayList<Integer>> FindPath (TreeNode root, int target) { // write code here dfs(root,target); return res_list; } public void dfs(TreeNode root, int target){ if(root == null) return; stack.add(root.val); if(root.left == null && root.right == null && target - root.val == 0){ res_list.add(new ArrayList<>(stack)); } dfs(root.left,target - root.val); dfs(root.right,target - root.val); stack.pop(); } }