当前位置:网站首页>Niuke-top101-bm29
Niuke-top101-bm29
2022-06-24 10:29:00 【A fish that eats cats】
The core idea : recursive
import java.util.*;
public class Solution {
public boolean hasPathSum (TreeNode root, int sum) {
// Empty node cannot find path
if(root == null)
return false;
// Leaf node , And the path and are sum
if(root.left == null && root.right == null && sum - root.val == 0)
return true;
// Recursion into child nodes
return hasPathSum(root.left, sum - root.val) || hasPathSum(root.right, sum - root.val);
}
}
边栏推荐
- 4.分类管理业务开发
- 5.菜品管理业务开发
- Distributed transaction principle and solution
- 学习使用php实现无限极评论和无限极转二级评论解决方案
- Caching mechanism for wrapper types
- 2022 International Symposium on intelligent robots and systems (isoirs 2022)
- Juul, the American e-cigarette giant, suffered a disaster, and all products were forced off the shelves
- Thread pool execution process
- numpy. logical_ or
- 线程的六种状态
猜你喜欢

SQL Sever中的窗口函数row_number()rank()dense_rank()

leetCode-2221: 数组的三角和

leetCode-498: 對角線遍曆

抓包工具charles实践分享

Practice sharing of packet capturing tool Charles

【Energy Reports期刊发表】2022年能源与环境工程国际会议(CFEEE 2022)

Leetcode-223: rectangular area

How to customize sharing links in wechat for H5 web pages

Leetcode-2221: triangular sum of arrays

uniapp 开发微信公众号,下拉框默认选中列表第一个
随机推荐
Leetcode-2221: triangular sum of arrays
The difference between static link library and dynamic link library
numpy. logical_ and()
Appium自动化测试基础 — 移动端测试环境搭建(一)
Leetcode interview question 16.06: minimum difference
学习使用phpstripslashe函数去除反斜杠
栈题目:函数的独占时间
【Energy Reports期刊发表】2022年能源与环境工程国际会议(CFEEE 2022)
Hill sorting graphic explanation + code implementation
Uniapp implementation forbids video drag fast forward
整理接口性能优化技巧,干掉慢代码
Resolved: methods with the same name as their class will not be constructors in
What are the characteristics of EDI local deployment and cloud hosting solutions?
解决微信小程序rich-text富文本标签内部图片宽高自适应的方法
百度网盘下载一直请求中问题解决
[IEEE publication] 2022 International Conference on intelligent transportation and future travel (cstfm 2022)
Practice sharing of packet capturing tool Charles
【资源分享】2022年第五届土木,建筑与环境工程国际会议(ICCAEE 2022)
如何在一个页面上使用多个KindEditor编辑器并将值传递到服务器端
uniapp实现点击拨打电话功能