It is getting crashed after q.push(make_pair(A,0)); I am not able to understand why it is breaking at that point saying segmentation fault


#1
int Solution::solve(string A, string B, vector<string> &C) {

    unordered_map<string,int>m;
    
    for(int i=0;i<C.size();i++){
        m[C[i]]=1;
    }
    m[B]=1;
    
    queue<pair<string,int>>q;
    q.push({A,0});
    while(!q.empty()){
        pair<string,int> pr=q.front();
        string s=pr.first;
        int index=pr.second;
        q.pop();
        if(s==B)return index;
        for(int i=0;i<s.size();i++){
            string s1=s;
            if(s1[i]!=B[i]){
                char h=s1[i];
                for(char ch='a';ch<='z';ch++){
                    s1[i]=ch;
                    if(m[s1]){
                        q.push({s1,index+1});
                        break;
                    }
                }
                s1[i]=h;
            }
        }
    }
    return 0;
}