Problem 3981 · Hard

Count Distinct Ways to Form Target from Two Strings

Track how many ways reach each pair of next-free indices in the two words, one target character at a time.

Open the interactive visualisation