–129求根节点的叶节点数字之和Java实现

This commit is contained in:
bourne-3
2021-09-07 12:20:01 +08:00
parent 41f2652d86
commit 3d1843da4a

View File

@ -168,7 +168,6 @@ Java
class Solution { class Solution {
List<Integer> path = new ArrayList<>(); List<Integer> path = new ArrayList<>();
int res = 0; int res = 0;
public int sumNumbers(TreeNode root) { public int sumNumbers(TreeNode root) {
// 如果节点为0那么就返回0 // 如果节点为0那么就返回0
if (root == null) return 0; if (root == null) return 0;
@ -200,7 +199,6 @@ class Solution {
} }
return; return;
} }
public int listToInt(List<Integer> path){ public int listToInt(List<Integer> path){
int sum = 0; int sum = 0;
for (Integer num:path){ for (Integer num:path){