Easy to understand Java solution
For each node in the tree we call the helper function.\n\nclass Solution {\n    int result = 0;\n    public int pathSum(TreeNode root, int sum) {\n        if(ro
For each node in the tree we call the helper function.\n```\nclass Solution {\n    int result = 0;\n    public int pathSum(TreeNode root, int sum) {\n        if(root == null) return 0;\n        helper(root, sum);\n        pathSum(root.left, sum);\n        pathSum(root.right, sum);\n        return result;\n    }\n    \n    public void helper(TreeNode root, int sum) {\n        if (root == null) return;\n        if (sum - root.val == 0) result+=1;\n        helper(root.left, sum-root.val);\n        helper(root.right, sum-root.val);\n    }\n}\n```
[]