MLE error in digital dictionary problem

#include
#include<bits/stdc++.h>
using namespace std;
class node{
public:
char ch;
unordered_map<char,node*>m;
bool terminat;
node(char data){
ch=data;
terminat=false;
}
};
class trie{
node * root;
public:
trie(){
root=new node(’\0’);
}
void insert(string s){
node * temp=root;

		for(int i=0;i<s.length();i++){
			char ch=s[i];
			if(temp->m[ch]==0){
				node * n=new node(ch);
				temp->m[ch]=n;
				temp=n;
			}
			else{
				temp=temp->m[ch];
			}
			
		}
		temp->terminat=true;
	}
	void prefix(string s){
		string ans="";
		node * temp=root;
		for(int i=0;i<s.length();i++){
			char ch=s[i];
		if(temp->m[ch]==0){
			cout<< "No suggestions"<<endl;
			return;
		}
		else{
			ans+=s[i];
			temp=temp->m[ch];
			
		}
		
		
		}
		
		printall(temp,s,"");
		
		
		
		}
		void printall(node* temp,string &s,string curr){
			if(temp->terminat){
				cout<<s+curr<<endl;
			}
			for(auto m1:temp->m){
				printall(m1.second,s,curr+m1.first);
			}
		}

};
int main() {
int n;
cin>>n;
trie t;
string s;
for(int i=0;i<n;i++){
cin>>s;
t.insert(s);
}
int q;
cin>>q;
while(q–){
cin>>s;
t.prefix(s);
}
}

hi @kumawatnitesh093,
refer, ive commented

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.