/**
 * struct TreeNode {
 *	int val;
 *	struct TreeNode *left;
 *	struct TreeNode *right;
 * };
 */
/**
 * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
 * @author Senky
 * @date 2023.07.28
 * @par url https://www.nowcoder.com/creation/manager/content/584337070?type=column&status=-1
 * @brief 加上了一个值而已,和算树的深度本质上没什么不同
 * @param root TreeNode类 
 * @param sum int整型 
 * @return bool布尔型
 */
#include <stdbool.h>
bool hasPathSum(struct TreeNode* root, int sum ) 
{
    // write code here
    if(root == NULL)
    {
        return false;
    }
    else if( sum == root->val && NULL == root->left && NULL == root->right) 
    {
        return true;
    }
    bool left = hasPathSum(root->left, sum - root->val);
    bool right = hasPathSum(root->right, sum - root->val); 

    return (left || right);
}