Idk why i am getting segmentation fault


#1

struct trie
{
struct trie* c[26];
bool end;
};
struct trie* get(void)
{
struct trie* newn=new trie;
for(int i=0;i<26;i++)
{
newn->c[i]=NULL;
}
newn->end=false;
return newn;
}
void insert(struct trie* A,string s)
{
struct trie* b=A;

for(int i=0;i<s.size();i++)

{
    if(!b->c[s[i]-'a'])
    {
        b->c[s[i]-'a']=get();
        
    }
    
    b=b->c[s[i]-'a'];
}

b->end=true;
}
void maketrie(trie* As,string A)
{
struct trie* b=As;
string s="";
for(int i=0;i<A.size();i++)
{
if(A[i]==’_’)
{
insert(b,s);
s=" ";
}
else
{
s+=A[i];
}
}
}

int search(struct trieA ,string s)
{
struct trie
b=A;
for(int i=0;i<s.size();i++)
{
if(!b->c[s[i]-‘a’])
{
return 0;
}
b=b->c[s[i]-‘a’];

}
if(b->end)
{
    return 1;
}
return 0;

}
vector Solution::solve(string A, vector &B)
{
struct trie* book=get();vector<pair<int,int>>v;
maketrie(book,A);
for(int i=0;i<B.size();i++)
{
int k=0;string str=" “;
for(int j=0;j<B[i].size();j++)
{
if(B[i][j]==’_’)
{
k+=search(book,str);
str=” ";
}
else
{
str+=B[i][j];
}
}
v.push_back(make_pair(k,i));
}
sort(v.begin(),v.end());
vectorvc;
for(int i=0;i<v.size();i++)
{
vc.push_back(v[i].second);
}
return vc;
}