一开始忘记了加else,调试了好久都木有找出问题,呜呜呜呜呜呜呜呜呜呜呜,细心啊啊啊啊~
var letterCombinations = function(digits) {
const dict={'2':'abc','3':'def','4':'ghi','5':'jkl','6':'mno','7':'pqrs','8':'tuv','9':'wxyz'};//用的对象,不是Map
let res=[];
if(digits.length!=0) backtracking("",digits);
return res;
function backtracking(temp,digits){
if(digits.length==0) res.push(temp);
else{
var letters=dict[digits[0]];
for(let letter of letters){
backtracking(temp+letter,digits.substr(1));
}
}
}
};