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.
Track how many ways reach each pair of next-free indices in the two words, one target character at a time.