class Solution {
public:
vector<string> result;
string worldPath;
map<char,vector<string>> myMap;
void map_init()
{
myMap.insert(pair<char,vector<string>>('2',{"a","b","c"})) ;
myMap.insert(pair<char,vector<string>>('3',{"d","e","f"})) ;
myMap.insert(pair<char,vector<string>>('4',{"g","h","i"})) ;
myMap.insert(pair<char,vector<string>>('5',{"j","k","l"})) ;
myMap.insert(pair<char,vector<string>>('6',{"m","n","o"})) ;
myMap.insert(pair<char,vector<string>>('7',{"p","q","r","s"})) ;
myMap.insert(pair<char,vector<string>>('8',{"t","u","v"})) ;
myMap.insert(pair<char,vector<string>>('9',{"w","x","y","z"})) ;
// for(auto it:myMap)
// cout<<it.first<<':'<<(it.second)[0]<<endl;
// cout<<myMap['2'].size();
}
void dfs(string digits , int fir )
{
if( worldPath.size() == digits.size())
{
result.push_back(worldPath);
return;
}
char num = digits[fir];
for(int j=0 ; j< myMap[num].size() ;j++)
{
worldPath += myMap[num][j];
dfs(digits,fir+1);
worldPath.pop_back();
}
return;
}
vector<string> letterCombinations(string digits) {
if(digits.size()==0) return result;
map_init();
dfs(digits,0);
return result;
}
};