C# dfs solution | 86ms 96%
Code\n\npublic class Solution {\n    public int PathSum(TreeNode root, int targetSum) \n    {\n        if(root == null) return 0;\n        \n        return Dfs(
# Code\n```\npublic class Solution {\n    public int PathSum(TreeNode root, int targetSum) \n    {\n        if(root == null) return 0;\n        \n        return Dfs(root, targetSum) \n            + PathSum(root.left, targetSum)\n            + PathSum(root.right, targetSum);\n\n        int Dfs(TreeNode node, long sum)\n        {\n            var s = node.val == sum ? 1 : 0;\n\n            if(node.left != null)\n                s += Dfs(node.left, sum-node.val);\n\n            if(node.right != null)\n                s += Dfs(node.right, sum-node.val);\n\n            return s;\n        }\n    }\n}\n```
['C#']