标签:ble strong ret roo node str sum || ++
Problem:
思路:
Solution (C++):
bool hasPathSum(TreeNode* root, int sum) {
if (root == NULL) return false;
if (root->val == sum && !root->left && !root->right) return true;
return hasPathSum(root->left, sum - root->val) || hasPathSum(root->right, sum - root->val);
}
性能:
Runtime: 8 ms??Memory Usage: 19.9 MB
标签:ble strong ret roo node str sum || ++
原文地址:https://www.cnblogs.com/dysjtu1995/p/12300561.html