Memory Limit exceeded?


#1

Can somebody tell me why am I getting partial score with MLE?

int mod(string t, int N)
{
    int r = 0;
    for (int i = 0; i < t.length(); i++)
    {
        r = r * 10 + (t[i] - '0');
        r %= N;
    }
    return r;
}

string Solution::multiple(int A) {
    queue <string> q;
    
    string word = "1";
    q.push(word);
    
    while (!q.empty()) {
        string u = q.front();
        q.pop();
        
        if (mod(u, A)==0)
            return u;
        
        q.push(u+"1");
        q.push(u+"0");
    }
    
    return word;
}

I figured that it throws MLE when A is quite big. Is it because my queue grows very large?