You are given three strings word1, word2, and target.
Return the total number of distinct ways to construct target by selecting and interleaving characters from word1 and word2.
A selection of characters is valid if:
The characters chosen from word1 maintain their relative order in word1.
The characters chosen from word2 maintain their relative order in word2.
At least word1 and at least word2.
The concatenated sequence of selected characters equals target.
Two ways are considered distinct if they use a different sequence of indices from word1 or word2.
Constraints:
word1.length, word2.length, target.length
word1, word2, and target consist of lowercase English letters only.
You are given three strings word1, word2, and target.
Return the total number of distinct ways to construct target by selecting and interleaving characters from word1 and word2.
A selection of characters is valid if:
The characters chosen from word1 maintain their relative order in word1.
The characters chosen from word2 maintain their relative order in word2.
At least word1 and at least word2.
The concatenated sequence of selected characters equals target.
Two ways are considered distinct if they use a different sequence of indices from word1 or word2.
Constraints:
word1.length, word2.length, target.length
word1, word2, and target consist of lowercase English letters only.