About question 4 their is not any another way to solve without using Trie because in my first instance it will seem familiar of recursion + memoization of pick or notPick because ultimately we have to calculate minimum cost to formed target string by using substring matching way on recursion by taking start index? Everyone only talking about using Trie to solve this question that's mean their is no another way left to solve this question.
Please fill the feedback form: forms.gle/52XsaRWXd2P4pBqz5
We can further optimize. Instead of storing index, we can store cost .Each time when we end at same char we store min cost
Isn't the code's complexity isn't N^2 in worst case? How does it pass the constraints?
Trie+DP fails few testcases within constraints.
Was expecting Rolling Hash+DP solution.
Yes
Yes
Truly helpful !!
solution of question 4 will give TLE.
About question 4 their is not any another way to solve without using Trie because in my first instance it will seem familiar of recursion + memoization of pick or notPick because ultimately we have to calculate minimum cost to formed target string by using substring matching way on recursion by taking start index? Everyone only talking about using Trie to solve this question that's mean their is no another way left to solve this question.
give a try using rolling hash
@@AMITKUMAR-sz4fg Can you elaborate more about rolling hash to solve this problem it will be more beneficial.
@@inspirationalshorts2689
Refer Coding mohan channel
He explained using rolling hash
Well explained!
Very helpful!