# 7.路径总和
![image-20201130112700554](https://raw.githubusercontent.com/TWDH/Leetcode-From-Zero/pictures/img/image-20201130112700554.png)
## 方法一:递归(Top-down)
[请首先阅读:递归top-down套路](../b.大赫的套路-递归.md)
#### 大神版写法:top-down
```java
class Solution {
public boolean hasPathSum(TreeNode root, int sum) {
//1.到达叶子节点后,判断当前路的总和是否和要求一致
if(root == null){
return sum == 0;
}
/** 上方条件换成这个也可以,容易理解
if (root == null) {
return false;