package main
import . "nc_tools"


func hasPathSum( root *TreeNode ,  sum int ) bool {
    // write code here
    if root == nil {
        return false
    }
    if root.Left == nil && root.Right == nil {
        return root.Val == sum
    }

    return hasPathSum(root.Left, sum - root.Val) || hasPathSum(root.Right, sum - root.Val)
}