编程题可以考虑用回溯吧,类比LC17 var combinations = function(digits) { if (!digits) return [] var result = [] var ind = 0 ​ var backTrack = (current, ind) => { if (ind === digits.length) { result.push(current) } else { digits[ind].forEach(l => backTrack(`${current}${l}`, ind + 1)) } } ​ backTrack('', 0) return result };
点赞 评论

相关推荐

牛客网
牛客企业服务