Java DFS Solution
\n\tpublic int pathSum(TreeNode root, int sum) {\n        if(root == null) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn pathSumFrom(root, sum) + pathSum(root.left, sum
```\n\tpublic int pathSum(TreeNode root, int sum) {\n        if(root == null) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn pathSumFrom(root, sum) + pathSum(root.left, sum) + pathSum(root.right, sum);\n    }\n\t\n\tprivate int pathSumFrom(TreeNode root, int sum) {\n\t\tif(root == null) {\n\t\t\treturn 0;\n\t\t}\n\t\tint s = pathSumFrom(root.left, sum-root.val) + pathSumFrom(root.right, sum-root.val);\n\t\tif(root.val == sum) {\n\t\t\ts++;\n\t\t}\n\t\treturn s;\n\t}\n```
[]