Two editors wrote short drafts, a and b, and you want one merged string that contains both drafts as subsequences: deleting some characters from the merged string gives a, and deleting some (possibly different) characters gives b.
Write shortestMergeLength(a, b) that returns the length of the shortest such merged string.
Input: a = "dark", b = "dart" Output: 5
darkt contains both. The shared dar is written once.
Input: a = "ab", b = "ab" Output: 2
The drafts are equal, so the merge is just ab.
1 <= a.length, b.length <= 1000Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #534 Shortest Merged Draft. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.