[C++] ✅Easy to understand DFS approach
\nclass Solution {\n    int count=0;\n    void getAllPath(TreeNode *root,long long targetSum){\n        if(root==NULL) return;\n        if(targetSum == root->va
```\nclass Solution {\n    int count=0;\n    void getAllPath(TreeNode *root,long long targetSum){\n        if(root==NULL) return;\n        if(targetSum == root->val){\n            count++;\n        }\n        getAllPath(root->left,targetSum-root->val);\n        getAllPath(root->right,targetSum-root->val);\n    }\npublic:\n    int pathSum(TreeNode* root, int targetSum) {\n        if(root==NULL) return 0;\n        getAllPath(root,targetSum);\n        pathSum(root->left,targetSum);\n        pathSum(root->right,targetSum);\n        return count;\n    }\n};\n```\nIf you like the solution, don\'t forget to upvote! :) \u2B06\uFE0F\n*Thanks!* \uD83D\uDE0A
['Depth-First Search', 'C']