
0 点赞 评论 收藏
分享
一世长安_:经典全排列改进版(回溯递归)
function pailie (arr) {
let res = []
const dfs = (path,index) => {
if(path.length == arr.length) {
res.push(path)
return
}
arr.forEach((n,i) => {
n.forEach(k => {
if(i == index) {
dfs(path + k,index+1)
}
})
})
}
dfs("",0)
return res
}

0 点赞 评论 收藏
分享
创作者周榜
更多
关注他的用户也关注了: