leetcode 17. 电话号码的字母组合
var letterCombinations = function(digits) {
if (!digits || digits === ' ') return []
let alpList = ['abc','def','ghi','jkl','mno','pqrs','tuv','wxyz']
let res = []
let len = digits.length - 1
let tmpStr = []
for(let i = 0;i <= len;i++){
let num = digits[i]-2
let alpCount = alpList[num].length - 1
tmpStr = []
let listLen = res.length - 1
if(i === 0){
for(let j = 0;j<=alpCount;j++){
res.push(alpList[num][j])
}
continue
}
for(let k = 0;k<=listLen;k++){
for(let j = 0;j<=alpCount;j++){
tmpStr.push(res[k]+alpList[num][j])
}
}
res = tmpStr
}
return res
};
思路:排列组合