Re: Simple AC Java Solution DFS

@star1993 hi, actually I have the same idea, but my solution can not figure out whether the subPath is linked together. for example, in the case

[10,5,-3,3,2,null,11,3,-2,null,1]

8

it will return 4 rather than 3, since it count (10) -> (-2) as 1 answer

```
public int pathSum(TreeNode root, int sum) {
if (root == null) {return 0;}
if (root.val == sum) {
return 1;}
else {
return (pathSum(root.left, sum - root.val) + pathSum(root.right, sum - root.val) + pathSum(root.left, sum) + pathSum(root.right, sum));
}
}
```

I tried to think of it pvernight but still confusing, can any one help me?