Minimum Number of Valid Strings to Form Target II
Store the words in a trie so each target position reads its longest valid piece in one walk, then run the cost DP over those reaches.
Store the words in a trie so each target position reads its longest valid piece in one walk, then run the cost DP over those reaches.