C++ straight forward solution
```\nclass Solution {\npublic:\n    int pathSum(TreeNode root, int sum) {\n        int res = 0;\n        pathSumHelper(root, sum, res, false);\n        return r
```\nclass Solution {\npublic:\n    int pathSum(TreeNode* root, int sum) {\n        int res = 0;\n        pathSumHelper(root, sum, res, false);\n        return res;\n    }\n    void pathSumHelper(TreeNode* root, int sum, int &res, bool parent_used) {\n        if (!root)\n            return;\n        if (sum - root->val == 0)\n            res++;\n        pathSumHelper(root->left, sum - root->val, res, true);\n        pathSumHelper(root->right, sum - root->val, res, true);\n        if (parent_used == false) { //if parent is part of the sum, then we cannot start a new path which jump over this node\n            pathSumHelper(root->left, sum, res, false);\n            pathSumHelper(root->right, sum, res, false);\n        }\n    }\n};\n````
[]