class Solution {
public:
const string letterMap[10] = {
"", // 0
"", // 1
"abc", // 2
"def", // 3
"ghi", // 4
"jkl", // 5
"mno", // 6
"pqrs", // 7
"tuv", // 8
"wxyz", // 9
};
vector<string> str_vec;
vector<string> ans;
string str;
void func(int i, int n){
if(i == n){
ans.push_back(str);
return;
}
for(char c : str_vec[i]){
str.push_back(c);
func(i + 1, n);
str.pop_back();
}
}
vector<string> letterCombinations(string digits) {
int n = digits.size();
for(char num : digits){
str_vec.push_back(letterMap[num - '0']);
}
if(n > 0){
func(0, n);
}
return ans;
}
};