pyassistant

Shortest Common Supersequence (multiple strings)

Given a list of strings, find the shortest string that is a supersequence of every string in the list. A string T is a supersequence of S if S can be obtained from T by deleting zero or more characters (i.e., S is a subsequence of T). If there are multiple shortest common supersequences, return the lexicographically smallest one. You must implement a function solve(strings: list[str]) -> str that returns the shortest common supersequence for the given list of strings. Notes: - Strings may contain arbitrary characters (assume Python strings), but all comparisons are standard lexicographic ordering. - The number of strings and their lengths may be moderate, and an efficient BFS over position-tuples with pruning is expected for full credit. - The solution must only use the provided function signature and return the result (no input/output operations).

Example:

Input:
(['abac', 'cab'])
Output:
'cabac'

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.