#3213
Construct String with Minimum Cost
grandmaster · 2225 · lc hard +32 · 19% accepted · 172 likes · top 1%
Description
You are given string target, string array words, and integer array costs of equal length.
Starting with empty string s, any number of times you may pick any index i, append words[i] to s, and pay costs[i].
Return the minimum total cost to make s == target, or -1 if impossible.
Code
1
2
3