var letterCombinations = function(digits) {
if(!digits) return [];
let map = {
'2': 'abc','3':'def','4':'ghi','5':'jkl','6':'mno','7':'pqrs','8':'tuv','9':'wxyz'
};
let res = [];
function dfs(index,path) {
if(index === digits.length) {
res.push(path);
return;
}
for (let i = 0;i < map[digits[index]].length;i++) {
path += map[digits[index]][i];
dfs(index+1,path.slice());
path = path.slice(0, path.length-1);
}
}
dfs(0,'');
return res;
};