其实我一开始读不懂题目。。我以为应该是出来的答案应该都是两位的,我还特地拷贝AC代码运行一下才知道题目意思= =虽然看了懂了题意还是不会做
代码挺容易懂的,运用递归,以level为digits的遍历指标,在遍历每个指标对应的text组成out,总的来说是DFS的运用

class Solution {
public:
vector<string> letterCombinations(string digits) {
string text[] = { "abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
vector<string>ans;
if (digits.empty())return ans;
string out = "";
letterConmbinationsDFS(digits, text, 0, out, ans);
return ans;
}
void letterConmbinationsDFS(string digits, string text[], int level, string out,
vector<string>& ans) {
if (level == digits.size())ans.push_back(out);
else {
string str = text[digits[level] - '2'];
for (int i = 0; i < str.size(); ++i) {
out.push_back(str[i]);
letterConmbinationsDFS(digits, text, level + 1, out, ans);
out.pop_back();
}
}
}
};