java DFS . easy to understand !!!
PLEASE upvote if helpful!!\n\n\nclass Solution {\n    int counter = 0;\n    public int pathSum(TreeNode root, int sum) {\n\n        if (root == null) return 0;\
**PLEASE upvote if helpful!!**\n\n```\nclass Solution {\n    int counter = 0;\n    public int pathSum(TreeNode root, int sum) {\n\n        if (root == null) return 0;\n\n        pathSumHelper(root, sum, 0);\n        pathSum(root.left, sum);\n        pathSum(root.right, sum);\n\n        return counter;\n\n    }\n\n    void pathSumHelper(TreeNode root, int sum, int currentSum) {\n        if (root == null) {\n            return;\n        }\n        currentSum += root.val;\n        if (currentSum == sum) {\n            counter++;\n        }\n        pathSumHelper(root.left, sum, currentSum);\n        pathSumHelper(root.right, sum, currentSum);\n    } \n}\n```
['Depth-First Search', 'Recursion', 'Java']