C++ Intuitive Solution
Solve with 2 DFS functions:\nThe first DFS traverse the tree and set each node as starting point\nThe second DFS visit subtree from the starting point\n\n\nclas
Solve with 2 DFS functions:\nThe first DFS traverse the tree and set each node as starting point\nThe second DFS visit subtree from the starting point\n\n```\nclass Solution {\npublic:\n    int ans = 0;\n    int pathSum(TreeNode* root, int sum) {\n        runAllNode(root, sum);\n        return ans;\n    }\n\n    void runAllNode(TreeNode* &current, int& target){\n        if(current){\n            updateAns(current, target, current->val);\n            runAllNode(current->left, target);\n            runAllNode(current->right, target);\n        }\n    }\n    \n    void updateAns(TreeNode* &current, int& target, int curSum){\n        if(curSum == target){\n            ans += 1;\n        }\n        if(current->left){\n            updateAns(current->left, target, curSum + current->left->val);\n        }\n        if(current->right){\n            updateAns(current->right, target, curSum + current->right->val);\n        }\n    }\n};\n```\n
['Depth-First Search', 'C']