Given a set S of m strings and a target string t we want to check whether or not t is the concatenation of some of the m strings while allowing repetition. Example : S= {ab, dbe, eaa, ea} and t=eaabdbeab. Here the answer is YES, t=ea ab dbe ab.
Key: I know that I should solve this using dynamic programming and I got this hint :
I should consider solving the following set of subproblems: can a prefix of T of length k be represented as a concatenation of some strings from S? These can be solved with a dynamic programming approach for all k from 1 up to the total length of T. The largest of these subproblems is the actual problem we want to solve.
But how can I write the code?
Thank you.