标签:dex empty put [] code oid www. inpu ack
https://www.cnblogs.com/grandyang/p/4452220.html
用迭代的方法,每次从3个字符中选择一个然后传给下一次迭代
class Solution { public: vector<string> letterCombinations(string digits) { vector<string> output; if(digits.empty()) return output; string dict[] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"}; combination(digits,dict,0,"",output); return output; } void combination(string digits,string dict[],int index,string input,vector<string> &output){ if(index == digits.size()){ output.push_back(input); return; } string str = dict[digits[index] - ‘0‘]; for(int i = 0;i < str.size();i++) combination(digits,dict,index+1,input + str[i],output); } };
17. Letter Combinations of a Phone Number
标签:dex empty put [] code oid www. inpu ack
原文地址:https://www.cnblogs.com/ymjyqsx/p/10498946.html