/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/funchasPathSum(root *TreeNode, targetSum int)bool{if root ==nil{returnfalse}
targetSum -= root.Val
if root.Left == root.Right {// root 是叶子return targetSum ==0}returnhasPathSum(root.Left, targetSum)||hasPathSum(root.Right, targetSum)}