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)
}
京公网安备 11010502036488号