Problem 3292 · Hard

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.

Open the interactive visualisation