| 15 | class Solution { |
| 16 | public: |
| 17 | bool hasPathSum(TreeNode* root, int targetSum) { |
| 18 | if(root == NULL) { |
| 19 | return false; |
| 20 | } |
| 21 | |
| 22 | targetSum = targetSum - root->val; |
| 23 | if(targetSum == 0 && root->left == NULL && root->right == NULL) { |
| 24 | return true; |
| 25 | } |
| 26 | |
| 27 | return hasPathSum(root->left, targetSum) || hasPathSum(root->right, targetSum); |
| 28 | } |
| 29 | }; |
nothing calls this directly
no test coverage detected