here is my code for digital dictionary
Still wrong answer
Hello,
Do two modifications, then your code will run perfectly.
-
Though it is not mentioned in the question, you have to insert the string or prefix that is not present in the dictionary(i.e. the vector you have created).
if(flag==0){
cout<<“No suggestions”<<endl;
v.push_back(h);
} -
now, when you are insert the string at last, the vector may become unsorted for some cases. You have to ensure that the vector should remain sorted.
Resolve above problems, and your code will run perfectly.
Suggestion: You can also use Trie data structure to implement this efficiently.
You can refer to my code, it is passing all the test cases.
click this.