We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
回溯是建立在 DFS 的基础之上的
const res = [] // path 路径 const target = [] const dfs = (source, deep, ...) => { // 状态变量 // 递归终止的条件 if (🤔) { // 存储满足条件的结果 res.push(target.slice()) // 返回 return } // 当前节点 for loop 横向遍历,向下分叉, index 视情况而定 for (let i = index; i < source.length; i++) { // 是否需要剪枝 // 做出选择 target.push(source[i]); // 深度递归,进入下一层 dfs(source, 🤔 + 1, ...); // 撤销选择 target.pop(); } return ans; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
回溯是建立在 DFS 的基础之上的
回溯模板
The text was updated successfully, but these errors were encountered: