leetcode 112 路径总和
作者:互联网
public boolean hasPathSum(TreeNode root, int sum) {
if (root == null){
return false;
}
if (root.left == null && root.right == null){
return sum == root.val;
}
return hasPathSum(root.left,sum-root.val) || hasPathSum(root.right,sum-root.val);
}
标签:hasPathSum,val,sum,112,return,null,root,leetcode,总和 来源: https://blog.csdn.net/Pausch/article/details/112060582