mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-14 02:10:37 +08:00
Update preorder_traversal_iii.
This commit is contained in:
@@ -37,7 +37,7 @@ const path = [];
|
||||
const res = [];
|
||||
preOrder(root, path, res);
|
||||
|
||||
console.log('\n输出所有根节点到节点 7 的路径,路径中不包含值为 3 的节点,仅包含一个值为 7 的节点');
|
||||
console.log('\n输出所有根节点到节点 7 的路径,路径中不包含值为 3 的节点');
|
||||
res.forEach((path) => {
|
||||
console.log(path.map((node) => node.val));
|
||||
});
|
||||
|
||||
@@ -38,7 +38,6 @@ function backtrack(state, choices, res) {
|
||||
if (isSolution(state)) {
|
||||
// 记录解
|
||||
recordSolution(state, res);
|
||||
return;
|
||||
}
|
||||
// 遍历所有选择
|
||||
for (const choice of choices) {
|
||||
|
||||
Reference in New Issue
Block a user