Update preorder_traversal_iii.

This commit is contained in:
krahets
2023-07-25 16:39:38 +08:00
parent 90af225dae
commit b067016bfa
20 changed files with 48 additions and 56 deletions
@@ -42,7 +42,7 @@ const path: TreeNode[] = [];
const res: TreeNode[][] = [];
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));
});
@@ -43,7 +43,6 @@ function backtrack(
if (isSolution(state)) {
// 记录解
recordSolution(state, res);
return;
}
// 遍历所有选择
for (const choice of choices) {