đź’ˇ Digital Dictionary question

i am getting wrong answer for test cases but i have taken care of case of strings in insertions and queries and also ensured lexicographic comparision pls help me

Hello @Pritika,

You said you are taking care of the lexicographical order.
But it is not printing the strings in lexicographical order.

Example:
4
pet
peter
rat
rack
5
pe
pet
r
rac
rat

Expected Output:
pet
peter
pet
peter
rack
rat
rack
rat

Your Output:
pet
peter
pet
peter
rat
rack
rack
rat

This is not mentioned in the problem but you have insert a string in the trie if it is not present as prefix.
if(temp==NULL){
cout<<“No suggestions”<<endl;
t.addword©;
}
This would not cause any error.

BTW, you need not to consider the cases. All the testcases are in lowercase.

If you still face issues, feel free to ask.
I would suggest to first try hard to solve this yourself.

Hope, this would help.
Give a like, if you are satisfied.

sir i tried the other way also but i was getting wrong ans

This code is working correct and solving the issue in point 1 of my previous reply.

Just integrate the modification specified in point 2, it will pass all the test cases.

Give a like if you are satisfied.
Mark this as resolved if you have no more doubts regarding this question.