Run time error plz help


  • -1
    R

    '''class Solution {
    public:
    void lettercom(string &digits,map<int,string> &checknum,vector<string> &ans,int begin,string &t)
    {
    if(begin==digits.length())
    {
    if(t.size()!=0)
    ans.push_back(t);
    return;
    }
    int tt=digits[begin]-'0';
    string s=checknum[tt];
    for(int i=0;i<s.length();i++)
    {
    t+=s[i];
    lettercom(digits,checknum,ans,begin+1,t);
    t.erase(t.end());
    }
    }

    vector<string> letterCombinations(string digits) {
        map<int,string> checknum;
        checknum[0]="";
        checknum[1]="";
        checknum[2]="abc";
        checknum[3]="def";
        checknum[4]="ghi";
        checknum[5]="jkl";
        checknum[6]="mno";
        checknum[7]="pqrs";
        checknum[8]="tuv";
        checknum[9]="wxyz";
        vector<string>ans;
        string t;
        lettercom(digits,checknum,ans,0,t);
        return ans;
    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.