Why it is giving (runtime error)(question included)
Don’t use maps, you can use arrays of size 26(as only lowercase letters are involved!)
Also your printfunction is not correct!
After going through given string to be searched, just execute DFS from last node of string (it will be in sorted order), also this DFS has a prefix s every time.
Eg lets say we have pet and peter in trie,
search for pe — after reaching e ,the last node, so DFS from e gives “t” and “ter” now just add “pe” to all DFS elements.
Also if such prefix doesn’t exists, don’t forget to add it in trie.
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.