Find Shortest Superstring

Find the shortest string that contains every given word as a contiguous substring. Precompute overlap lengths between all word pairs, then use DP over bitmasks (traveling-salesman style) to find the optimal concatenation order.

Examples
Input: ["y","yy"]
Output: "yy"
Hints

Find Shortest Superstring

Find the shortest string that contains every given word as a contiguous substring. Precompute overlap lengths between all word pairs, then use DP over bitmasks (traveling-salesman style) to find the optimal concatenation order.