#375 · Dynamic programming · Advanced · 135 XP · about 25 min
Shuffle two strings together like the two halves of a deck of cards: take characters from the front of a or from the front of b, one at a time, in any pattern, until both are used up. The characters of each string keep their own order. For example, "abc" and "xy" can make "axbyc", "xyabc" or "abxcy", but not "bacxy".
Write is_interleaving(a, b, c) that returns True if c can be made this way from a and b, and False otherwise.
is_interleaving("dog", "cat", "dcoagt") # returns True is_interleaving("ab", "ab", "abba") # returns False is_interleaving("abc", "", "abc") # returns True
0 <= len(a), len(b) <= 2500 <= len(c) <= 600First solves only, ranked by stars and then time.