简单的回溯法!
class Solution {public: void backTrack(string digits, vectorwords, string ans, vector & res, int k, int flag[]) { if(k == digits.size()) { res.push_back(ans); } else { for(int i=0; i letterCombinations(string digits) { string ans; int flag[4] = { 0,};//0为未用过 vector words = { "","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; vector res; if(digits == "") return res; backTrack(digits,words,ans,res,0,flag); return res; }};