Simplest solution | Easiest to understand
\nclass Solution {\n    \n    public int pathSum(TreeNode root, int targetSum) {\n        \n        if(root==null)\n            return 0;\n        \n        ret
```\nclass Solution {\n    \n    public int pathSum(TreeNode root, int targetSum) {\n        \n        if(root==null)\n            return 0;\n        \n        return helper(root,targetSum) + pathSum(root.left, targetSum) + pathSum(root.right, targetSum);\n    }\n    \n    public int helper(TreeNode root, long sum) {\n     \n        if(root==null)\n            return 0;\n        \n        int res=0;\n        \n        if(root.val==sum)\n            res++;\n        \n        res+= helper(root.left,sum-root.val);\n        res+= helper(root.right,sum-root.val);\n        \n        return res;\n    }\n}\n```
[]