17.电话号码的字母组合

思路:排列组合题目一般都可以用递归+回溯的思路做

public:
    map> m{{'2',{'a','b','c'}},{'3',{'d','e','f'}},{'4',{'g','h','i'}},{'5',{'j','k','l'}},{'6',{'m','n','o'}},{'7',{'p','q','r','s'}},{'8',{'t','u','v'}},{'9',{'w','x','y','z'}}};
    vector letterCombinations(string digits) {

        vector res;
        if(digits.size()==0)
            return res;

        backtracking("",0,digits,res);

        return res; 
    }

    void backtracking(string tmp, int i,string s,vector& res )
    {
        if(tmp.size()==s.length())
        {
            //cout< v=m[s[i]];

        for(int j=0;j

你可能感兴趣的:(17.电话号码的字母组合)