标签:com let app cpp ble ber push tco ati
https://leetcode.com/problems/letter-combinations-of-a-phone-number/
class Solution {
public:
    string mapping[8]={"abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    void get_string(string &digits,int l,vector<string> &ans,string &x){
        if(l==digits.size()){
            ans.push_back(x);
            return;
        }
        for(auto &e:mapping[digits[l]-'2']){
            x.push_back(e);
            get_string(digits,l+1,ans,x);
            x.pop_back();
        }
        
        
    }
    vector<string> letterCombinations(string digits) {
        /*
        注意考虑digits空的情况。
        */
        vector<string> ans;
        if(digits.empty()) return ans;
        string x;
        get_string(digits,0,ans,x);
        return ans;
    }
};Leetcode 17. Letter Combinations of a Phone Number
标签:com let app cpp ble ber push tco ati
原文地址:https://www.cnblogs.com/ximelon/p/10804268.html