C++ Simple Solution || Recursive
\nclass Solution {\npublic:\n    void solve(TreeNode *root,int targetSum,vector<int> &sum,int &c)\n    {\n        if(!root)\n            return;\n        sum.pu
```\nclass Solution {\npublic:\n    void solve(TreeNode *root,int targetSum,vector<int> &sum,int &c)\n    {\n        if(!root)\n            return;\n        sum.push_back(root->val);\n        long long int csum=0;\n        for(int i=sum.size()-1;i>=0;i--)\n        {\n            csum+=sum[i];\n            if(csum==targetSum)\n                c++;\n        }\n        solve(root->left,targetSum,sum,c);\n        solve(root->right,targetSum,sum,c);\n        sum.pop_back();\n    }\n    int pathSum(TreeNode* root, int targetSum) {\n        int c=0;\n        vector<int> sum;\n        solve(root,targetSum,sum,c);\n        return c;\n    }\n};\n```\n**IF YOU LIKE IT , DO UPVOTE**\n**HAPPY CODING;**
['Recursion', 'C', 'C++']