Any ideas are appreciated. Thx!

```
class Solution {
public:
int pathSum(TreeNode* root, int sum) {
if (root == NULL)
return 0;
int a = 0, b = 0, c = 0;
if (root -> left != NULL)
{
a = pathSum(root -> left, sum - root -> val);
if (root -> val != 0)
a += pathSum(root -> left, sum);
}
if (root -> right != NULL)
{
b = pathSum(root -> right, sum - root -> val);
if (root -> val != 0)
b += pathSum(root -> right, sum);
}
if (root -> val == sum)
c = 1;
return a + b + c;
}
};
```