class Solution {public: string mapping[8]={"abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; void get_string(string &digits,int l,vector&ans,string &x){ if(l==digits.size()){ ans.push_back(x); return; } for(auto &e:mapping[digits[l]-'2']){ x.push_back(e); get_string(digits,l+1,ans,x); x.pop_back(); } } vector letterCombinations(string digits) { /* 注意考虑digits空的情况。 */ vector ans; if(digits.empty()) return ans; string x; get_string(digits,0,ans,x); return ans; }};