mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
129求根节点的叶节点数字之和Java实现
This commit is contained in:
@ -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){
|
||||||
|
Reference in New Issue
Block a user