leetcode 112.路径总和bool hasPathSum(struct TreeNode* root, int targetSum) { if(root==NULL) { return false; } if(root->left==NULL&&root->right==NULL) { return targetSum==root->val; } if(root->left) { if(hasPathSum(root->left, targetSum-root->val))return true; } if(root->right) { if(hasPathSum(root->right, targetSum-root->val))return true; } return false;}