pull/944/head
krahets 1 year ago
parent 175cf59c9d
commit c865d20b93

@ -432,6 +432,7 @@ comments: true
if (root.val == 7) { if (root.val == 7) {
// 记录解 // 记录解
res.add(new ArrayList<>(path)); res.add(new ArrayList<>(path));
path.remove(path.size() - 1);
return; return;
} }
preOrder(root.left); preOrder(root.left);
@ -455,6 +456,7 @@ comments: true
if (root->val == 7) { if (root->val == 7) {
// 记录解 // 记录解
res.push_back(path); res.push_back(path);
path.pop_back();
return; return;
} }
preOrder(root->left); preOrder(root->left);
@ -477,6 +479,7 @@ comments: true
if root.val == 7: if root.val == 7:
# 记录解 # 记录解
res.append(list(path)) res.append(list(path))
path.pop()
return return
pre_order(root.left) pre_order(root.left)
pre_order(root.right) pre_order(root.right)
@ -498,6 +501,7 @@ comments: true
if int(root.Val) == 7 { if int(root.Val) == 7 {
// 记录解 // 记录解
*res = append(*res, *path) *res = append(*res, *path)
*path = (*path)[:len(*path)-1]
return return
} }
preOrderIII(root.Left, res, path) preOrderIII(root.Left, res, path)
@ -521,6 +525,7 @@ comments: true
if (root.val === 7) { if (root.val === 7) {
// 记录解 // 记录解
res.push([...path]); res.push([...path]);
path.pop();
return; return;
} }
preOrder(root.left, path, res); preOrder(root.left, path, res);
@ -548,6 +553,7 @@ comments: true
if (root.val === 7) { if (root.val === 7) {
// 记录解 // 记录解
res.push([...path]); res.push([...path]);
path.pop();
return; return;
} }
preOrder(root.left, path, res); preOrder(root.left, path, res);
@ -577,6 +583,7 @@ comments: true
if (root.val == 7) { if (root.val == 7) {
// 记录解 // 记录解
res.Add(new List<TreeNode>(path)); res.Add(new List<TreeNode>(path));
path.RemoveAt(path.Count - 1);
return; return;
} }
preOrder(root.left); preOrder(root.left);
@ -600,6 +607,7 @@ comments: true
if root.val == 7 { if root.val == 7 {
// 记录解 // 记录解
res.append(path) res.append(path)
path.removeLast()
return return
} }
preOrder(root: root.left) preOrder(root: root.left)

Loading…
Cancel
Save