#494 · Dynamic programming · Expert · 270 XP · about 55 min
A superstring of a list of words is a string that contains every word as a run of consecutive characters. Words may overlap inside it: "catapult" contains "cat", "tap" and "pult".
Write shortest_superstring_length(words) that returns the length of the shortest possible superstring.
shortest_superstring_length(["cat", "tap", "pult"]) # returns 8 shortest_superstring_length(["ab", "bc", "abc"]) # returns 3 shortest_superstring_length(["xyz"]) # returns 3
In the second example "abc" already contains the other two words.
1 <= len(words) <= 12First solves only, ranked by stars and then time.