class Solution { public: map<char,string> coll; vector<string> vec; public: vector<string> letterCombinations(string digits) { if(digits.length()==0) return vec; f(); digui(0,digits,""); return vec; } void f() { coll.insert(pair<char,string>('2',"abc")); coll.insert(pair<char,string>('3',"def")); coll.insert(pair<char,string>('4',"ghi")); coll.insert(pair<char,string>('5',"jkl")); coll.insert(pair<char,string>('6',"mno")); coll.insert(pair<char,string>('7',"pqrs")); coll.insert(pair<char,string>('8',"tuv")); coll.insert(pair<char,string>('9',"wxyz")); } void digui(int i,string str,string res) { if(i==str.length()) { vec.push_back(res); return ; } string tem=coll[str[i]]; for(int k=0;k<tem.length();++k) digui(i+1,str,res+tem[k]); } };