[leetcode] 电话号码的排列组合
17. 电话号码的字母组合 - 力扣(LeetCode)
class Solution {vector<string> ans;string path;const string keymap[10] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
public:vector<string> letterCombinations(string digits) {if(digits.size() == 0) return ans;dfs(digits, 0);return ans;}void dfs(string digits, int pos){if(pos == digits.size()){ans.push_back(path);return;}for(auto& ch : keymap[digits[pos] - '0']){path.push_back(ch);dfs(digits, pos + 1);path.pop_back();}}
};