This is Shortest Common Supersequence from LeetCode. Given two strings, find the shortest string that has both as subsequences. For "abac" and "cab", the answer is "cabac". This is the inverse of LCS.
Instead of finding the longest common part, you're building the shortest string containing both. The minimum length equals . Find the LCS first, then reconstruct the supersequence.