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?
for example:
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.
background:
GCC seems to do an optimization where it combines string literals that share the same suffix.
https://stackoverflow.com/questions/51551068/
So I want to broaden this problem.