一、题目内容
二、题解
解法1:
思路
代码
public class Solution {boolean has = false;public boolean hasPathSum (TreeNode root, int sum) {// write code hererecur(root, sum);return has;}private void recur(TreeNode root, int sum){if (root == null) {return;}sum -= root.val;if(sum == 0 && root.left == null && root.right == null){has = true;return;}recur(root.left, sum);recur(root.right, sum);}}
