[C++] DFS clean solution [ T : 89%, M : 80% ]
Please upvote if you found the post helpful :)\nShoutout to @prateeksharma. \n\nclass Solution {\npublic:\n    int ans=0;\n    int pathSum(TreeNode* root, int s
***Please upvote if you found the post helpful :)***\nShoutout to @prateeksharma. \n```\nclass Solution {\npublic:\n    int ans=0;\n    int pathSum(TreeNode* root, int sum) {\n        if(root){\n            dfs(root,sum);\n            pathSum(root->left,sum);\n            pathSum(root->right,sum);\n        }\n        return ans;\n    }\n    void dfs(TreeNode* root, int sum){\n        if(!root)return;\n        if(root->val==sum)ans++;\n        dfs(root->left,sum-root->val);\n        dfs(root->right,sum-root->val);\n    }\n};\n```
['Depth-First Search', 'C', 'C++']