Untitled
unknown
c_cpp
4 years ago
574 B
5
Indexable
bool hasPathSum(TreeNode* root, int targetSum) { if(root == NULL) return false; if(root->val == targetSum){ if(root->left == NULL && root->right == NULL) return true; } bool left, right; left = hasPathSum(root->left, targetSum - root->val); right= hasPathSum(root->right, targetSum - root->val); if(left == true) return true; if(right == true) return true; return false; }
Editor is loading...