Given a set of input strings, how do I find a shortest string S so that all input strings appear as a substring of S?
foobar + bar -> foobar foo + bar + rfo -> barfoo
I guess it's related to graphs, but don't know how to solve it.
- first check all the "substrings", for example, "bar" to "foobar". Remove "bar".
- the more two string share head and tail, the more likely they will be joined together, like nodes in a graph.
GCC seems to do an optimization where it combines string literals that share the same suffix.
So I want to broaden this problem.