LEETCODE- Letter Combinations of a Phone Number.(STOI IS GIVING ERROR )

MY CODE IS GIVING ERROR >>>terminate called after throwing an instance of ‘std::invalid_argument’ what(): stoi

WHY USING STOI (COVERT STRING TO INT) FUNCTION ON LEETCODE COMPILER IS GIVING ERROR WHILE MY CODE RUNS FINE ON OTHER COMPILER??

#include <iostream>
using namespace std;
#include<bits/stdc++.h>

void res(int num ,vector<string>&ans,string *choices,string output)
    {
      
        if(num==0)
        {
            ans.push_back(output);
            return ;
        }
            
    string s=choices[num%10];
    
    for(int i=0;i<s.size();i++)
    {
        res(num/10,ans,choices,s[i]+output);
    }
    
            
                

        
    }
    vector<string> letterCombinations(string digits)
    {
    vector<string>ans;
    string choices[] = { " ", " ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" }; 
    res(stoi(digits),ans,choices,"");
        return ans;
        
        
    }

//TO TEST THE CODE
int main() {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
string a;
cin>>a;
 vector<string>ans=letterCombinations(a);


for(auto it:ans)
{
    cout<<it<<endl;
}

}