(TreeNode root,String S, ArrayList<String> list)
| 10 | } |
| 11 | |
| 12 | public static boolean paths(TreeNode root,String S, ArrayList<String> list) |
| 13 | { |
| 14 | if(root.left==null && root.right==null) |
| 15 | { |
| 16 | list.add(S+root.val); |
| 17 | return true; |
| 18 | } |
| 19 | if(root.left!=null) paths(root.left,S+root.val+"->",list); |
| 20 | if(root.right!=null) paths(root.right,S+root.val+"->",list); |
| 21 | return true; |
| 22 | } |
| 23 | } |