class Solution {
public:
void dfs(string digits, int idx, map<char,string> hash, string path, vector<string>& res){
if(idx==digits.size()){
res.push_back(path);
return;
}
for(char ch:hash[digits[idx]]){
path+=ch;
dfs(digits,idx+1,hash,path,res);
path.pop_back();
}
}
vector<string> letterCombinations(string digits) {
if(digits.size()==0) return {};
map<char,string> hash={{'2',"abc"},{'3',"def"},{'4',"ghi"},{'5',"jkl"},{'6',"mno"},{'7',"pqrs"},{'8',"tuv"},{'9',"wxyz"}};
string path="";
vector<string> res;
dfs(digits,0, hash,path,res);
return res;
}
};