MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / paths

Method paths

TreeBinaryTreePaths.java:12–22  ·  view source on GitHub ↗
(TreeNode root,String S, ArrayList<String> list)

Source from the content-addressed store, hash-verified

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}

Callers 1

binaryTreePathsMethod · 0.95

Calls 1

addMethod · 0.45

Tested by

no test coverage detected