1 Star 1 Fork 1

Clock966 / LeetcodeEveryday

forked from 四方云和 / LeetcodeEveryday 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
PathSum.java 371 Bytes
一键复制 编辑 原始数据 按行查看 历史
RunAtWorld 提交于 2020-03-31 00:18 . Java 语言解答 package
package solution;
public class PathSum {
public boolean hasPathSum(TreeNode root, int sum) {
if (root == null) {
return false;
}
if (root.left == null && root.right == null) {
return root.val == sum;
}
sum -= root.val;
return hasPathSum(root.left, sum) || hasPathSum(root.right, sum);
}
}
1
https://gitee.com/Clock966/LeetcodeEveryday.git
git@gitee.com:Clock966/LeetcodeEveryday.git
Clock966
LeetcodeEveryday
LeetcodeEveryday
master

搜索帮助