diff --git a/Leetcode/Pathsum.cpp b/Leetcode/Pathsum.cpp index dbc50a4..76b3bfc 100644 --- a/Leetcode/Pathsum.cpp +++ b/Leetcode/Pathsum.cpp @@ -5,15 +5,12 @@ class Solution { return false; } pres_sum+=root->val; - if(root->left == NULL and root->right == NULL){ + if(root->left == NULL && root->right == NULL){ return pres_sum == targetSum; } return havingPathSum(root->left,targetSum,pres_sum) || havingPathSum(root->right,targetSum,pres_sum); } bool hasPathSum(TreeNode* root, int targetSum) { - if(root == NULL){ - return false; - } return havingPathSum(root,targetSum,0); }